<!--用在机加的过程能力趋势预判系统上 -->
<!--管理员：代码：1:可以做所有的操作；
               2:可以上传结果(精测)
               2:可以上传结果(手检)
               4：只能查看-->
<template>
  <div style="margin: 0;padding: 0">
    <el-container>
      <!--页面表头设计-->
      <el-header style="height: 39px">
        <el-link class="headMain" href="http://10.255.96.48:3404/">{{main.qualityManagementSystem}}</el-link>
        <span class="center-text">{{main.processCapabilityMonitoring}}</span>
        <el-popover
            placement="top-start"
            title="用户信息"
            width="200"
            trigger="hover">
          <div style="margin-top: 10px">Name：{{useName}}</div>
          <div style="margin-top: 10px">ID:{{useId}}</div>
          <div style="margin-top: 10px" @click="logOut"><el-link>退出</el-link></div>
          <div class="headMain" slot="reference">{{useName}}</div>
        </el-popover>
      </el-header>
      <el-container>
        <el-aside width="200px" style="height: 90vh">
          <el-input
              :placeholder="pageVal.filter"
              v-model="filterText">
          </el-input>
          <el-tree style="margin: 10px 8px;"
                   :data="treeTesting"
                   :props="defaultProps"
                   @node-click="treeClick"
                   :filter-node-method="filterNode"
                   highlight-current="highlight-current"
                   ref="tree">
          </el-tree>
          <el-tree style="margin: 10px 8px;"
                   :data="treeTesting1"
                   :props="defaultProps"
                   @node-click="treeClick"
                   :filter-node-method="filterNode"
                   highlight-current="highlight-current"
                   ref="tree">
          </el-tree>
        </el-aside>
        <el-container>
          <!--主题设计-->
          <el-main style="height: 79vh;overflow: auto">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <!--检测项目-->
              <el-tab-pane :label="pageVal.measurementItem" name="first">
                <div style="margin-top: 5px">
                  <el-link @click="tableShow(1,null)"
                  v-if="treeUseNode!==null && usePower===1">{{pageVal.add}}</el-link>
                </div>
                <div style="margin-top: 5px">
                  <el-table :data="tableData" style="width: 100%" border height="64vh">
                    <!-- 顺序号 -->
<!--                    <el-table-column-->
<!--                        prop="order_number"-->
<!--                        :label="pageVal.order"-->
<!--                        width="60">-->
<!--                    </el-table-column>-->
                    <!-- 检测项目名称 project -->
                    <el-table-column
                        prop="measuring_project"
                        :label="pageVal.measurementItem"
                        v-slot:default="scope">
                      <span v-if="scope.row.measuring_project.split('|*|').length<3">{{scope.row.measuring_project}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_project.split('|*|')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_project.split('|*|')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_project.split('|*|')[2]}}</span>
                    </el-table-column>
                    <!-- 检测要求 requirement -->
                    <el-table-column
                        prop="measuring_requirement"
                        :label="pageVal.measurementRequirement" v-slot:default="scope">
                      <span v-if="scope.row.measuring_requirement.split('|*|').length<3">{{scope.row.measuring_requirement}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_requirement.split('|*|')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_requirement.split('|*|')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_requirement.split('|*|')[2]}}</span>
                    </el-table-column>
                    <!-- 测量类型 -->
                    <el-table-column
                        prop="measuring_type"
                        :label="pageVal.measurementType"
                        width="80">
                    </el-table-column>
                    <!-- 上公差 -->
                    <el-table-column
                        prop="upper_tolerance"
                        :label="pageVal.upperTolerance"
                        width="80">
                    </el-table-column>
                    <!-- 下公差 lower -->
                    <el-table-column
                        prop="lower_tolerance"
                        :label="pageVal.lowerTolerance"
                        width="80">
                    </el-table-column>

                    <!-- 标准值 -->
                    <el-table-column
                        prop="standard_value"
                        :label="pageVal.standardValue"
                        width="80">
                    </el-table-column>

                    <!-- 检测频次 -->
                    <el-table-column
                        prop="measuring_frequency"
                        :label="pageVal.measurementFrequency"
                        width="80">
                    </el-table-column>

                    <!-- 实施部门 department -->
                    <el-table-column
                        prop="department"
                        :label="pageVal.department"
                        width="110"
                        v-slot:default="scope">
                      <span v-if="languageS==='chinese'">{{scope.row.department.split('/')[0]}}</span>
                      <span v-if="languageS==='english'">{{scope.row.department.split('/')[1]}}</span>
                      <span v-if="languageS==='russian'">{{scope.row.department.split('/')[2]}}</span>
                    </el-table-column>
                    <!-- 精测/手检 -->
                    <el-table-column
                        prop="precision_hand"
                        :label="pageVal.precision_hand"
                        width="110"
                        v-slot:default="scope">
                      <span v-if="languageS==='chinese'">{{scope.row.precision_hand.split('/')[0]}}</span>
                      <span v-if="languageS==='english'">{{scope.row.precision_hand.split('/')[1]}}</span>
                      <span v-if="languageS==='russian'">{{scope.row.precision_hand.split('/')[2]}}</span>
                    </el-table-column>
                    <!-- 编辑 -->
                    <el-table-column
                        prop="editName"
                        :label="pageVal.edit"
                        width="80" v-if="usePower===1"
                        v-slot:default="scope"
                        align="center">
                      <div v-if="scope.row.project_type===2 || scope.row.project_type===3">
                        <el-link @click="tableShow(2,scope)" style="margin-right: 6px"><i class="el-icon-edit"></i></el-link>
                        <el-link @click="tableShow(3,scope)" style="margin-right: 6px"><i class="el-icon-d-caret"></i></el-link>
                        <el-link @click="deleteDataShow('deleteMeasuringProjectOneRow',scope)"><i class="el-icon-delete"></i></el-link>
                      </div>
                    </el-table-column>
                  </el-table>
                </div>
              </el-tab-pane>
              <!--数据录入-->
              <el-tab-pane :label="pageVal.dataEntry" name="second">
                <div style="text-align: left;overflow-x: auto">
                    <el-form :inline="true" @submit.prevent>
                      <el-form-item :label="pageVal.partNumber">
                        <el-input v-model="part_number" @blur="partNumEdit" size="mini" style="width: 150px"></el-input>
                      </el-form-item>
                      <el-form-item :label="pageVal.measurementDate">
                        <el-date-picker
                            v-model="measuring_date"
                            @blur="measuringDateEdit"
                            type="date"
                            :placeholder="pageVal.selectDate"
                            value-format="yyyy-MM-dd"
                            format="yyyy-MM-dd"
                            style="width: 150px" size="mini">
                        </el-date-picker>
                      </el-form-item>
                      <el-form-item :label="pageVal.measurementPerson">
                        <el-input v-model="measuring_person" @change="measuringPersonEdit" style="width: 180px" size="mini"></el-input>
                      </el-form-item>
                      <el-form-item :label="pageVal.shift">
                        <el-select v-model="measuring_shift" @change="workShiftEdit" :placeholder="pageVal.select" style="width: 180px" size="mini">
                          <el-option
                              v-for="item in workShiftOptions"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value">
                          </el-option>
                        </el-select>
                      </el-form-item>
                      <el-form-item>
                        <el-button @click="tableTestSave" size="mini" v-if="usePower===1 || usePower===2 || usePower===3">{{pageVal.save}}</el-button>
                      </el-form-item>
                      <el-form-item>
                        <el-upload
                        ref="excelUpload"
                        action="http://10.255.96.48:3499/russiaEngine/"
                        :show-file-list="false"
                        :auto-upload="false"
                        accept=".xlsx, .xls"
                        :on-change="handleUploadSuccess"
                        :on-error="handleUploadError">
                        <el-button size="mini" v-if="usePower===1 || usePower==='1'">{{pageVal.uploadEXCEL}}</el-button>
                        </el-upload>
                      </el-form-item>
                      <el-form-item>
                        <el-upload
                            ref="excelUpload"
                            action="http://10.255.96.48:3499/russiaEngine/"
                            :show-file-list="false"
                            :auto-upload="false"
                            accept=".xlsx, .xls"
                            :on-change="handleUploadDataSuccessGT"
                            :on-error="handleUploadError">
                          <el-button size="mini" v-if="(this.treeUseNode?.parent?.parent?.data?.label==='机加车间' || this.treeUseNode?.parent?.parent?.data?.label==='Machining workshop' || this.treeUseNode?.parent?.parent?.data?.label==='Цех механической обработки') && (usePower===1 || usePower===2)">{{pageVal.uploadBlock}}</el-button>
                        </el-upload>
                      </el-form-item>
                      <el-form-item>
                        <el-upload
                            ref="excelUpload"
                            action="http://10.255.96.48:3499/russiaEngine/"
                            :show-file-list="false"
                            :auto-upload="false"
                            accept=".xlsx, .xls"
                            :on-change="handleUploadDataSuccess"
                            :on-error="handleUploadError">
                          <el-button size="mini" v-if="(this.treeUseNode?.parent?.parent?.data?.label==='机加车间' || this.treeUseNode?.parent?.parent?.data?.label==='Machining workshop' || this.treeUseNode?.parent?.parent?.data?.label==='Цех механической обработки') && (usePower===1 || usePower===2)">{{pageVal.uploadHead}}</el-button>
                        </el-upload>
                      </el-form-item>
                      <el-form-item>
                        <el-upload
                            ref="excelUpload"
                            action="http://10.255.96.48:3499/russiaEngine/"
                            :show-file-list="false"
                            :auto-upload="false"
                            accept=".xlsx, .xls"
                            :on-change="handleUploadDataSuccessHand"
                            :on-error="handleUploadError">
                          <el-button size="mini" v-if="(this.treeUseNode?.parent?.parent?.data?.label==='机加车间-手检' || this.treeUseNode?.parent?.parent?.data?.label==='Machining workshop-Hand inspection' || this.treeUseNode?.parent?.parent?.data?.label==='Цех механической обработки-Ручное осмотрение')  && (usePower===1 || usePower===3)">{{pageVal.uploadHand}}</el-button>
                        </el-upload>
                      </el-form-item>
                    </el-form>
                </div>
                <div style="margin-top: -5px">
                  <el-table :data="tableTest" style="width: 100%" border>
                    <!-- 检测项目名称 -->
                    <el-table-column
                        prop="measuring_project"
                        :label="pageVal.measurementItem"
                        v-slot:default="scope">
                      <span v-if="scope.row.measuring_project.split('|*|').length<3">{{scope.row.measuring_project}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_project.split('|*|')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_project.split('|*|')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_project.split('|*|')[2]}}</span>
                    </el-table-column>
                    <!-- 检测要求 requirement -->
                    <el-table-column
                        prop="measuring_requirement"
                        :label="pageVal.measurementRequirement" v-slot:default="scope">
                      <span v-if="scope.row.measuring_requirement.split('|*|').length<3">{{scope.row.measuring_requirement}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_requirement.split('|*|')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_requirement.split('|*|')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_requirement.split('|*|')[2]}}</span>
                    </el-table-column>
                    <!-- 上公差 -->
                    <el-table-column
                        prop="upper_tolerance"
                        :label="pageVal.upperTolerance"
                        width="70">
                    </el-table-column>
                    <!-- 下公差 -->
                    <el-table-column
                        prop="lower_tolerance"
                        :label="pageVal.lowerTolerance"
                        width="70">
                    </el-table-column>
                    <!-- 标准值 -->
                    <el-table-column
                        prop="standard_value"
                        :label="pageVal.standardValue"
                        width="70">
                    </el-table-column>
                    <el-table-column
                        prop="part_number"
                        :label="pageVal.partNumber1"
                        width="140"
                        v-slot:default="scope">
                      <el-input v-model="scope.row.part_number"></el-input>
                    </el-table-column>
                    <el-table-column
                        prop="measuring_date"
                        :label="pageVal.measurementDate1"
                        width="130"
                        v-slot:default="scope">
                      <el-input v-model="scope.row.measuring_date"></el-input>
                    </el-table-column>
                    <el-table-column
                        prop="measuring_person"
                        :label="pageVal.measurementPerson1"
                        width="100"
                        v-slot:default="scope">
                      <el-input v-model="scope.row.measuring_person"></el-input>
                    </el-table-column>
                    <el-table-column
                        prop="measuring_shift"
                        :label="pageVal.shift1"
                        width="100"
                        v-slot:default="scope">
                      <el-select v-model="scope.row.measuring_shift" placeholder="请选择" style="width: 80px">
                        <el-option
                            v-for="item in workShiftOptions"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                        </el-option>
                      </el-select>
                    </el-table-column>
                    <el-table-column
                        prop="measuring_value"
                        :label="pageVal.actualValue"
                        width="100"
                        v-slot:default="scope">
                      <el-input v-model="scope.row.measuring_value" @input="testValEditHand(scope)"></el-input>
                    </el-table-column>
                    <el-table-column
                    :label="pageVal.assessment"
                    width="50px"
                    v-slot="scope">
                      <div style="display: flex; justify-content: center; align-items: center; height: 100%;">
                        <span  style="display: inline-block; width: 20px; height: 20px; border-radius: 50%;background-color: black" v-if="scope.row.isOk==='空'"></span>
                        <span  style="display: inline-block; width: 20px; height: 20px; border-radius: 50%;background-color: limegreen" v-else-if="scope.row.isOk==='是'"></span>
                        <span  style="display: inline-block; width: 20px; height: 20px; border-radius: 50%;background-color: red" v-else-if="scope.row.isOk==='否'"></span>
                      </div>
                    </el-table-column>
                  </el-table>
                </div>
              </el-tab-pane>
              <!--作业指导书-->
              <el-tab-pane :label="pageVal.workingInstrction" name="workBook">
                开发中
              </el-tab-pane>
              <!--趋势管理-->
              <el-tab-pane :label="pageVal.trendManagement" name="trendManagement">
                <div style="display: flex;margin-left: 10px;margin-right: 10px;height:34vh;overflow: auto">
                  <!--折线图-->
                  <div style="flex: 1;  border: 1px solid blue; margin-right: 10px">
                    <div ref="lineChart" style="width: 100%;height: 100%; margin-top: 17px"></div>
                  </div>
                  <!--ppk-->
                  <div style=" border: 1px solid blue; width: 200px; margin-right: 10px">
                    <div>
                      <!-- PPK/CPK 结果显示 -->
                      <div style="text-align: left; margin-left: 20px">
                        <p><strong style="color: red; font-size: 18px">ppk：{{ ppkResult.ppk }}</strong></p>
                        <p><strong style="color: red; font-size: 18px">cpk：{{ ppkResult.cpk }}</strong></p>
                      </div>
                      <!-- 趋势检测结果显示 -->
                      <div v-if="trendResult" style="text-align: left; margin-left: 20px">
                        <p>
                          <strong style="color: red; font-size: 18px">是否连续六点上升：{{ trendResult.hasContinuousIncreasing !== undefined ? (trendResult.hasContinuousIncreasing ? 'yes' : 'no') : '' }}</strong>
                          <el-link
                              v-if="trendResult.hasContinuousIncreasing"
                              @click="showTrendDialog('increasing')"
                              style="margin-left: 5px">
                            <i class="el-icon-view"></i>
                          </el-link>
                        </p>
                        <p>
                          <strong style="color: red; font-size: 18px">是否连续六点下降：{{ trendResult.hasContinuousDecreasing !== undefined ? (trendResult.hasContinuousDecreasing ? 'yes' : 'no') : '' }}</strong>
                          <el-link
                              v-if="trendResult.hasContinuousDecreasing"
                              @click="showTrendDialog('decreasing')"
                              style="margin-left: 5px">
                            <i class="el-icon-view"></i>
                          </el-link>
                        </p>
                      </div>
                    </div>
                  </div>
                  <!--选择？组数据-->
                  <div style="width: 150px; border: 1px solid blue;overflow: auto">
                    <div style="margin-top: 8px">
                      <el-button style="width: 130px" :style="{ backgroundColor:chartBackground25 , color:chartColor25}" @click="clickQuantityButton(25)">25组数据</el-button>
                    </div>
                    <div style="margin-top: 8px">
                      <el-button style="width: 130px" :style="{ backgroundColor:chartBackground50 , color:chartColor50}" @click="clickQuantityButton(50)">50组数据</el-button>
                    </div>
                    <div style="margin-top: 8px">
                      <el-button style="width: 130px" :style="{ backgroundColor:chartBackground125 , color:chartColor125}" @click="clickQuantityButton(125)">125组数据</el-button>
                    </div>
                    <div style="margin-top: 8px">
                      <el-button style="width: 130px" :style="{ backgroundColor:chartBackground300 , color:chartColor300}" @click="clickQuantityButton(300)">300组数据</el-button>
                    </div>
                    <div style="margin-top: 8px">
                      <el-button style="width: 130px" :style="{ backgroundColor:chartBackground500 , color:chartColor500}" @click="clickQuantityButton(500)">500组数据</el-button>
                    </div>
                  </div>
                </div>
                <div style="display: flex;margin-left: 10px;margin-right: 10px;margin-top:10px;height:33vh;overflow: auto">
                  <!--直方图-->
                  <div style="flex: 1;  border: 1px solid blue; margin-right: 10px">
                    <div ref="barChart" style="height:100%; width:100%; margin-top: 15px"></div>
                  </div>
                  <!--移动极差图-->
                  <div style="flex: 1;  border: 1px solid blue; margin-right: 10px">
                    <div ref="movingRangeChart" style="height: 100%; width:100%; margin-top: 15px"></div>
                  </div>
                  <div style="width: 360px; border: 1px solid blue;">
                    <el-table
                        :data="tableData"
                        border
                        height="100%"
                        @row-click="handleClickChart"
                        :row-style="measuringProjectRowClassName">
                      <!-- 序号 -->
                      <el-table-column
                          :label="pageVal.order"
                          width="60"
                          align="center"
                          v-slot:default="scope">
                        {{scope.$index+1}}
                      </el-table-column>
                      <!-- 检测项目名称 project -->
                      <el-table-column
                          prop="measuring_project"
                          :label="pageVal.measurementItem"
                          v-slot:default="scope">
                        <span v-if="scope.row.measuring_project.split('|*|').length<3">{{scope.row.measuring_project}}</span>
                        <span v-else-if="languageS==='chinese'">{{scope.row.measuring_project.split('|*|')[0]}}</span>
                        <span v-else-if="languageS==='english'">{{scope.row.measuring_project.split('|*|')[1]}}</span>
                        <span v-else-if="languageS==='russian'">{{scope.row.measuring_project.split('|*|')[2]}}</span>
                      </el-table-column>
                    </el-table>
                  </div>
                </div>
              </el-tab-pane>
              <!--原始数据-->
              <el-tab-pane :label="pageVal.rawData" name="rawData">
                <div style="text-align: left;overflow-x: auto">
                  <el-form :inline="true" @submit.prevent>
                    <el-form-item :label="pageVal.measurementItem">
                      <el-input v-model="measuring_project" size="mini" style="width: 160px"></el-input>
                    </el-form-item>
                    <el-form-item :label="pageVal.partNumber">
                      <el-input v-model="part_number" size="mini" style="width: 160px"></el-input>
                    </el-form-item>
                    <el-form-item :label="pageVal.measurementDate">
                      <el-date-picker
                          v-model="measuring_date"
                          type="date"
                          :placeholder="pageVal.selectDate"
                          value-format="yyyy-MM-dd"
                          format="yyyy-MM-dd"
                          style="width: 160px" size="mini">
                      </el-date-picker>
                    </el-form-item>
                    <el-form-item :label="pageVal.measurementPerson">
                      <el-input v-model="measuring_person" style="width: 160px" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item :label="pageVal.shift">
                      <el-select v-model="measuring_shift" :placeholder="pageVal.select" style="width: 175px" size="mini">
                        <el-option
                            v-for="item in workShiftOptions"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item>
                      <el-button type="primary" size="mini" @click="handleFilter">
                        <i class="el-icon-search"></i>
                      </el-button>
                      <el-button size="mini" @click="resetFilter">
                        <i class="el-icon-refresh"></i>
                      </el-button>
                    </el-form-item>
                  </el-form>
                </div>
                <div style="margin-top: -5px" :key="componentKey">
                  <el-table
                      :data="filteredTableData"
                      style="width: 100%"
                      border
                      :height="originalDataHeight">
                    <!-- 检测项目名称 -->
                    <el-table-column
                        prop="measuring_project"
                        :label="pageVal.measurementItem"
                        width="160"
                        align="center"
                        v-slot:default="scope">
                      <span v-if="scope.row.measuring_project.split('|*|').length<3">{{scope.row.measuring_project}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_project.split('|*|')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_project.split('|*|')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_project.split('|*|')[2]}}</span>
                    </el-table-column>
                    <!-- 检测要求  -->
                    <el-table-column
                        prop="measuring_requirement"
                        :label="pageVal.measurementRequirement"
                        width="125"
                        align="center"
                        v-slot:default="scope">
                      <span v-if="scope.row.measuring_requirement.split('|*|').length<3">{{scope.row.measuring_requirement}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_requirement.split('|*|')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_requirement.split('|*|')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_requirement.split('|*|')[2]}}</span>
                    </el-table-column>
                    <!-- 上公差 -->
                    <el-table-column
                        prop="upper_tolerance"
                        :label="pageVal.upperTolerance"
                        width="70"
                        align="center">
                    </el-table-column>
                    <!-- 下公差 -->
                    <el-table-column
                        prop="lower_tolerance"
                        :label="pageVal.lowerTolerance"
                        width="70"
                        align="center">
                    </el-table-column>
                    <!-- 标准值 -->
                    <el-table-column
                        prop="standard_value"
                        :label="pageVal.standardValue"
                        width="70"
                        align="center">
                    </el-table-column>
                    <!-- 工件号 -->
                    <el-table-column
                        prop="part_number"
                        :label="pageVal.partNumber1"
                        width="140"
                        align="center">
                    </el-table-column>
                    <!-- 检测日期 -->
                    <el-table-column
                        prop="measuring_date"
                        :label="pageVal.measurementDate1"
                        width="120"
                        align="center">
                    </el-table-column>
                    <!-- 测量人 -->
                    <el-table-column
                        prop="measuring_person"
                        :label="pageVal.measurementPerson1"
                        width="105"
                        align="center">
                    </el-table-column>
                    <!-- 检测班次 -->
                    <el-table-column
                        prop="measuring_shift"
                        :label="pageVal.shift1"
                        width="100"
                        align="center"
                        v-slot:default="scope">
                      <span v-if="scope.row.measuring_shift.split('/').length<3">{{scope.row.measuring_shift}}</span>
                      <span v-else-if="languageS==='chinese'">{{scope.row.measuring_shift.split('/')[0]}}</span>
                      <span v-else-if="languageS==='english'">{{scope.row.measuring_shift.split('/')[1]}}</span>
                      <span v-else-if="languageS==='russian'">{{scope.row.measuring_shift.split('/')[2]}}</span>
                    </el-table-column>
                    <!-- 测量值 -->
                    <el-table-column
                        prop="measuring_value"
                        :label="pageVal.actualValue"
                        width="105"
                        align="center"
                        v-slot:default="scope">
                      {{ formatDecimal(scope.row.measuring_value, 3) }}
                    </el-table-column>
                    <!-- 是否计算ppk -->
                    <el-table-column
                        prop="is_ppk"
                        :label="pageVal.isPpk"
                        width="100"
                        align="center">
                    </el-table-column>
                    <!-- 不计算原因 -->
                    <el-table-column
                        prop="no_calculate_reason"
                        :label="pageVal.noCalculateReason"
                        width="120"
                        align="center">
                    </el-table-column>
                    <!-- 编辑 -->
                    <el-table-column
                        :label="pageVal.edit"
                        align="center"
                        v-slot:default="scope"
                        v-if="usePower===1">
                      <el-link style="margin-right: 8px" @click="measuringValueEditShow(1,scope)">
                        <i class="el-icon-edit"></i>
                      </el-link>
                      <el-link style="margin-right: 8px" @click="deleteDataShow('deleteMeasuringValueOneRow',scope)">
                        <i class="el-icon-delete"></i>
                      </el-link>
                      <el-link @click="removeMeasuringValueOneRow(1,scope)">
                        <i class="el-icon-scissors"></i>
                      </el-link>
                    </el-table-column>
                  </el-table>
                  <!-- 分页控件 -->
                  <el-pagination
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                      :current-page="measuringResultPagination.currentPage"
                      :page-sizes="[10, 20, 50, 100]"
                      :page-size="measuringResultPagination.pageSize"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="measuringResultPagination.total">
                  </el-pagination>
                </div>
              </el-tab-pane>
              <!--管理中台-->
              <el-tab-pane label="管理中台" name="third">管理中台</el-tab-pane>
              <!--模型说明-->
              <el-tab-pane label="模型说明" name="forth">模型说明</el-tab-pane>
            </el-tabs>
          </el-main>
          <el-footer style="height: 44px">
            <el-button plain size="mini" @click="languageSelect('chinese')">中  文</el-button>
            <el-button plain size="mini" @click="languageSelect('russian')">Русский язык</el-button>
            <el-button plain size="mini" @click="languageSelect('english')">English</el-button>
          </el-footer>
        </el-container>
      </el-container>
    </el-container>

    <!--弹窗放置区-->
    <!--删除某一条数据的弹窗-->
    <el-dialog
        :title="titleUse"
        :visible.sync="deleteDataDialog"
        width="400px"
        :before-close="handleClose">
      <span>{{pageVal.sureToDelete}}</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="deleteDataDialog = false" size="mini">{{pageVal.cancel}}</el-button>
        <el-button type="primary"  size="mini" @click="deleteDataOk">{{pageVal.ok}}</el-button>
      </span>
    </el-dialog>

    <!--新增、编辑项目的弹窗，这个页面只有自行控制的项目-->
    <el-dialog
        :title="titleUse"
        :visible.sync="tableFormDialog"
        width="610px"
        :before-close="handleClose">
      <el-form ref="tableForm" status-icon :model="tableForm"  label-width="100px">
        <div style="display: flex;">
          <div>
            <!-- 第一项内容 -->
            <el-form-item label="产品图号：">
              <el-input v-model="tableForm.drawing_number" placeholder="产品图号" disabled></el-input>
            </el-form-item>
          </div>
          <div>
            <!-- 第二项内容 -->
            <el-form-item label="工序号：">
              <el-input v-model="tableForm.op" placeholder="工序号" disabled></el-input>
            </el-form-item>
          </div>
        </div>
        <el-form-item label="实施部门：">
          <el-select v-model="tableForm.department" placeholder="实施部门" style="width: 100%">
            <el-option
                v-for="item in departmentOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="项目名称：" label-width="120">
          <el-input v-model="text1" placeholder="项目名称"></el-input>
        </el-form-item>
        <el-form-item label="项目名称(英)：" label-width="120">
          <el-input v-model="text2" placeholder="项目名称"></el-input>
        </el-form-item>
        <el-form-item label="项目名称(俄)：" label-width="130">
          <el-input v-model="text3" placeholder="项目名称"></el-input>
        </el-form-item >
        <el-form-item label="检测要求：" label-width="150">
          <el-input v-model="text4" placeholder="检测要求"></el-input>
        </el-form-item>
        <el-form-item label="检测要求(英)：" label-width="150">
          <el-input v-model="text5" placeholder="检测要求"></el-input>
        </el-form-item>
        <el-form-item label="检测要求(俄)：" label-width="150">
          <el-input v-model="text6" placeholder="检测要求"></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.precision_hand">
          <el-select v-model="tableForm.precision_hand" style="width: 100%">
            <el-option
                v-for="item in precisionHandOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <div style="display: flex;">
          <div>
            <!-- 第一项内容 -->
            <el-form-item label="检测频次：">
              <el-select v-model="tableForm.measuring_frequency" placeholder="频次" style="width: 100%">
                <el-option
                    v-for="item in frequencyOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
          <div>
            <!-- 第二项内容 -->
            <el-form-item label="检测类型：">
              <el-select v-model="tableForm.measuring_type" placeholder="请选择" style="width: 100%">
                <el-option
                    v-for="item in testTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </div>
        </div>
        <div style="display: flex;" v-if="tableForm.measuring_type===1">
          <div>
            <!-- 第一项内容 -->
            <el-form-item label="标准值：">
              <el-input v-model="tableForm.standard_value" placeholder="标准值"></el-input>
            </el-form-item>
          </div>
          <div>
            <!-- 第二项内容 -->
            <el-form-item label="上公差：">
              <el-input v-model="tableForm.upper_tolerance" placeholder="上公差"></el-input>
            </el-form-item>
          </div>
          <div>
            <!-- 第三项内容 -->
            <el-form-item label="下公差：">
              <el-input v-model="tableForm.lower_tolerance" placeholder="下公差"></el-input>
            </el-form-item>
          </div>
        </div>
        <el-form-item label="信息确认：">
          <el-button  @click="tableFormDialog=false">{{pageVal.cancel}}</el-button>
          <el-button type="primary" @click="tableDataEdit">{{pageVal.ok}}</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <!--编辑检测项目的顺序-->
    <el-dialog
        :title="titleUse"
        :visible.sync="editOrderDialog"
        width="1000px"
        :before-close="handleClose">
      <el-table :data="tableOrderData" style="width: 100%" border height="64vh">
        <!-- 检测项目名称 project -->
        <el-table-column
            prop="measuring_project"
            :label="pageVal.measurementItem"
            v-slot:default="scope">
          <span v-if="scope.row.measuring_project.split('|*|').length<3">{{scope.row.measuring_project}}</span>
          <span v-else-if="languageS==='chinese'">{{scope.row.measuring_project.split('|*|')[0]}}</span>
          <span v-else-if="languageS==='english'">{{scope.row.measuring_project.split('|*|')[1]}}</span>
          <span v-else-if="languageS==='russian'">{{scope.row.measuring_project.split('|*|')[2]}}</span>
        </el-table-column>
        <!-- 检测要求 requirement -->
        <el-table-column
            prop="measuring_requirement"
            :label="pageVal.measurementRequirement" v-slot:default="scope">
          <span v-if="scope.row.measuring_requirement.split('|*|').length<3">{{scope.row.measuring_requirement}}</span>
          <span v-else-if="languageS==='chinese'">{{scope.row.measuring_requirement.split('|*|')[0]}}</span>
          <span v-else-if="languageS==='english'">{{scope.row.measuring_requirement.split('|*|')[1]}}</span>
          <span v-else-if="languageS==='russian'">{{scope.row.measuring_requirement.split('|*|')[2]}}</span>
        </el-table-column>
        <!-- 测量类型 -->
        <el-table-column
            prop="measuring_type"
            :label="pageVal.measurementType"
            width="80">
        </el-table-column>
        <!-- 上公差 -->
        <el-table-column
            prop="upper_tolerance"
            :label="pageVal.upperTolerance"
            width="80">
        </el-table-column>
        <!-- 下公差 lower -->
        <el-table-column
            prop="lower_tolerance"
            :label="pageVal.lowerTolerance"
            width="80">
        </el-table-column>

        <!-- 标准值 -->
        <el-table-column
            prop="standard_value"
            :label="pageVal.standardValue"
            width="80">
        </el-table-column>

        <!-- 检测频次 -->
        <el-table-column
            prop="measuring_frequency"
            :label="pageVal.measurementFrequency"
            width="80">
        </el-table-column>

        <!-- 实施部门 department -->
        <el-table-column
            prop="department"
            :label="pageVal.department"
            width="110"
            v-slot:default="scope">
          <span v-if="languageS==='chinese'">{{scope.row.department.split('/')[0]}}</span>
          <span v-if="languageS==='english'">{{scope.row.department.split('/')[1]}}</span>
          <span v-if="languageS==='russian'">{{scope.row.department.split('/')[2]}}</span>
        </el-table-column>
        <!-- 精测/手检 -->
        <el-table-column
            prop="precision_hand"
            :label="pageVal.precision_hand"
            width="110"
            v-slot:default="scope">
          <span v-if="languageS==='chinese'">{{scope.row.precision_hand.split('/')[0]}}</span>
          <span v-if="languageS==='english'">{{scope.row.precision_hand.split('/')[1]}}</span>
          <span v-if="languageS==='russian'">{{scope.row.precision_hand.split('/')[2]}}</span>
        </el-table-column>
        <!-- 编辑 -->
        <el-table-column
            prop="editName"
            :label="pageVal.edit"
            width="80" v-if="usePower===1"
            v-slot:default="scope"
            align="center">
          <div v-if="scope.row.project_type===2 || scope.row.project_type===3">
            <el-link @click="editOrder(1,scope)" style="margin-right: 8px"><i class="el-icon-top"></i></el-link>
            <el-link @click="editOrder(2,scope)"><i class="el-icon-bottom"></i></el-link>
          </div>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editOrderDialog = false" size="mini">{{pageVal.cancel}}</el-button>
        <el-button type="primary"  size="mini" @click="editOrderOk">{{pageVal.ok}}</el-button>
      </span>
    </el-dialog>

    <!--编辑某一条检测结果-->
    <el-dialog
        :title="titleUse"
        :visible.sync="measuringValueEditDialog"
        width="400px"
        :before-close="handleClose">
      <el-form :inline="true" ref="tableTestValForm" :model="tableTestValForm" label-width="150px" size="small">
        <el-form-item :label="pageVal.measurementItem">
          <el-input v-model="tableTestValForm.measuring_project" disabled></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.measurementRequirement">
          <el-input v-model="tableTestValForm.measuring_requirement" disabled></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.upperTolerance" required>
          <el-input v-model="tableTestValForm.upper_tolerance"></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.lowerTolerance" required>
          <el-input v-model="tableTestValForm.lower_tolerance"></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.standardValue" required>
          <el-input v-model="tableTestValForm.standard_value"></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.partNumber1" required>
          <el-input v-model="tableTestValForm.part_number"></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.measurementDate1" required>
          <el-date-picker
              v-model="tableTestValForm.measuring_date"
              type="date"
              value-format="yyyy-MM-dd"
              format="yyyy-MM-dd"
              style="width: 200px">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="pageVal.measurementPerson1" required>
          <el-input v-model="tableTestValForm.measuring_person"></el-input>
        </el-form-item>
        <el-form-item :label="pageVal.shift1" required>
          <el-select v-model="tableTestValForm.measuring_shift" style="width: 200px">
            <el-option
                v-for="item in workShiftOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="pageVal.actualValue" required>
          <el-input v-model="tableTestValForm.measuring_value"></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="measuringValueEditDialog = false" size="mini">{{pageVal.cancel}}</el-button>
        <el-button type="primary" @click="measuringValueEditOk" size="mini">{{pageVal.ok}}</el-button>
      </span>
    </el-dialog>

    <!--编辑是否计算ppk-->
    <el-dialog
        :title="titleUse"
        :visible.sync="ppkDialog"
        width="400px"
        :before-close="handleClose">
      <el-form :inline="true" ref="tableTestValForm" :model="tableTestValForm" label-width="150px" size="small">
        <el-form-item :label="pageVal.isPpk" required>
          <el-select v-model="tableTestValForm.is_ppk" style="width: 200px">
            <el-option
                v-for="item in isPpkOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="pageVal.noCalculateReason" required>
          <el-input v-model="tableTestValForm.no_calculate_reason" rows="3"></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="ppkDialog = false" size="mini">{{pageVal.cancel}}</el-button>
        <el-button type="primary" @click="ppkEditOk" size="mini">{{pageVal.ok}}</el-button>
      </span>
    </el-dialog>

    <!--显示连续六点上升/下降数据的弹窗-->
    <el-dialog
        :title="titleUse"
        :visible.sync="continuousDataDialog"
        width="80%">
      <el-table
          :data="continuousData"
          style="width: 100%"
          border
          :height="originalDataHeight">
        <!-- 检测项目名称 -->
        <el-table-column
            prop="measuring_project"
            :label="pageVal.measurementItem"
            align="center"
            v-slot:default="scope">
          <span v-if="scope.row.measuring_project.split('|*|').length<3">{{scope.row.measuring_project}}</span>
          <span v-else-if="languageS==='chinese'">{{scope.row.measuring_project.split('|*|')[0]}}</span>
          <span v-else-if="languageS==='english'">{{scope.row.measuring_project.split('|*|')[1]}}</span>
          <span v-else-if="languageS==='russian'">{{scope.row.measuring_project.split('|*|')[2]}}</span>
        </el-table-column>
        <!-- 检测要求  -->
        <el-table-column
            prop="measuring_requirement"
            :label="pageVal.measurementRequirement"
            width="100"
            align="center"
            v-slot:default="scope">
          <span v-if="scope.row.measuring_requirement.split('|*|').length<3">{{scope.row.measuring_requirement}}</span>
          <span v-else-if="languageS==='chinese'">{{scope.row.measuring_requirement.split('|*|')[0]}}</span>
          <span v-else-if="languageS==='english'">{{scope.row.measuring_requirement.split('|*|')[1]}}</span>
          <span v-else-if="languageS==='russian'">{{scope.row.measuring_requirement.split('|*|')[2]}}</span>
        </el-table-column>
        <!-- 上公差 -->
        <el-table-column
            prop="upper_tolerance"
            :label="pageVal.upperTolerance"
            width="70"
            align="center">
        </el-table-column>
        <!-- 下公差 -->
        <el-table-column
            prop="lower_tolerance"
            :label="pageVal.lowerTolerance"
            width="70"
            align="center">
        </el-table-column>
        <!-- 标准值 -->
        <el-table-column
            prop="standard_value"
            :label="pageVal.standardValue"
            width="70"
            align="center">
        </el-table-column>
        <!-- 工件号 -->
        <el-table-column
            prop="part_number"
            :label="pageVal.partNumber1"
            width="140"
            align="center">
        </el-table-column>
        <!-- 检测日期 -->
        <el-table-column
            prop="measuring_date"
            :label="pageVal.measurementDate1"
            width="120"
            align="center">
        </el-table-column>
        <!-- 检测班次 -->
        <el-table-column
            prop="measuring_shift"
            :label="pageVal.shift1"
            width="100"
            align="center"
            v-slot:default="scope">
          <span v-if="scope.row.measuring_shift.split('/').length<3">{{scope.row.measuring_shift}}</span>
          <span v-else-if="languageS==='chinese'">{{scope.row.measuring_shift.split('/')[0]}}</span>
          <span v-else-if="languageS==='english'">{{scope.row.measuring_shift.split('/')[1]}}</span>
          <span v-else-if="languageS==='russian'">{{scope.row.measuring_shift.split('/')[2]}}</span>
        </el-table-column>
        <!-- 测量值 -->
        <el-table-column
            prop="measuring_value"
            :label="pageVal.actualValue"
            width="105"
            align="center"
            v-slot:default="scope">
          {{ formatDecimal(scope.row.measuring_value, 3) }}
        </el-table-column>
      </el-table>
    </el-dialog>

    <!--抽屉放置区域-->
  </div>
</template>

<script>
import {
  departmentOptions,
  frequencyOptions,
  testTypeOptions,
  tree_amc_product_op_chinese, tree_amc_product_op_english, tree_amc_product_op_russian, tree_amc_product_ops_chinese,
} from "@/configUse";
import * as XLSX from "xlsx";
import _ from "lodash";
import * as echarts from "echarts";

//—————————————————————————————————————————————————————————————————————————————————
//—————————————————————————————————————————————————————————————————————————————————
export default {
  name: "macTestCon",
  components: {},
  data() {
    return {
      componentKey: 0, // 用于强制刷新组件

      //控制原始数据表格高度的变量
      originalDataHeight:window.visualViewport.height-340,

      activeName: 'first',//用户权限相关的变量
      useName: '',//用户名称
      useId: '',//用户编号
      usePower: '',//用户权限

      //记录用户选择的语言
      languageS:'chinese',
      main:{
        qualityManagementSystem:'俄动力质量管理系统',
        processCapabilityMonitoring:'频次检测管理-机加检验',
      },
      pageVal:{
        order:'序号',
        ok:'确定',
        cancel:'取消',
        save:'保存',
        select:'请选择',
        selectDate:'选择日期',
        sureToDelete:'确定删除数据吗？',
        add:'新增',
        filter:'输入关键字进行过滤',
        measurementItem:'检测项目',
        measurementRequirement:'检测要求',
        measurementType:'测量类型',
        upperTolerance:'上公差',
        lowerTolerance:'下公差',
        standardValue:'标准值',
        measurementFrequency:'检测频次',
        department:'实施部门',
        precision_hand:'精测/手检',
        edit:'编辑',

        dataEntry:'数据录入',
        partNumber:'工件号：',
        measurementDate:'检测日期：',
        measurementPerson:'测量人：',
        shift:'班次：',
        uploadEXCEL:'上传项目',
        uploadBlock:'上传报告(缸体)',
        uploadHead:' 上传报告(缸盖)',
        uploadHand:'上传报告(手检)',
        partNumber1:'工件号',
        measurementDate1:'检测日期',
        measurementPerson1:'测量人',
        shift1:'班次',
        actualValue:'实测值',
        assessment:'判定',
        isPpk:'计算ppk',
        noCalculateReason:'不计算ppk原因',

        workingInstrction:'作业指导书',
        trendManagement:'趋势管理',
        rawData:'原始数据',
      },

      //—————————————————————————————————————————————————————————————————————————————————
      //导航栏相关的变量
      filterText:'',
      //精测树形结构
      treeTesting:tree_amc_product_op_chinese,
      //手检树形结构
      treeTesting1:tree_amc_product_ops_chinese,
      //树形的导航用到的数据模板
      defaultProps: {
        children: 'children',
        label: 'label'
      },

      //用户点击了哪一个工序
      treeUseOp:'',
      //用户点击了那个产品
      treeUseProduct:'',
      //用户点击的树形结构节点
      treeUseNode:null,

      //—————————————————————————————————————————————————————————————————————————————————
      //判断用户要删除哪个数据
      deleteDataDoe:'',

      //检测项目的主表
      tableData: [{
        id: null, // 主键
        create_time: null, // 创建时间
        update_time: null, // 修改时间
        creator: '', // 编辑人
        process_status:'',//流程状态
        sys_update_user:'',//更新人
        sys_audit_user:'',//审核人
        sys_audit_time:'',//审核时间
        sys_deleted: 0, //删除标记位 (0表示未删除)
        workshop: '', //车间名称三种语言（‘/’分割）
        drawing_number: '', //产品图号
        op: '', //工序号
        measuring_project: '', //检测项目名称（三种语言，用||隔开）
        measuring_requirement: '', //检测要求（三种语言，用||隔开）
        measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
        upper_tolerance: 0.0, //上公差
        lower_tolerance: 0.0, //下公差
        standard_value: 0.0, //标准值
        measuring_frequency: '', //检测频次（是一个固定内容，查附录）
        department: '', //实施部门（是一个固定值，查附录）
        precision_hand: '',//手检/精测
        project_type: 0, //检测类型，和控制计划的关系（固定值，查附录）
        order_number: 0, //顺序号
        control_plan_id: 0 //控制计划关联号（记录控制计划id）
      }],
      //检测项目的表单控制
      tableForm:{
        id: null, // 主键
        create_time: null, // 创建时间
        update_time: null, // 修改时间
        creator: '', // 编辑人
        process_status:'',//流程状态
        sys_update_user:'',//更新人
        sys_audit_user:'',//审核人
        sys_audit_time:'',//审核时间
        sys_deleted: 0, //删除标记位 (0表示未删除)
        workshop: '', //车间名称三种语言（‘/’分割）
        drawing_number: '', //产品图号
        op: '', //工序号
        measuring_project: '', //检测项目名称（三种语言，用||隔开）
        measuring_requirement: '', //检测要求（三种语言，用||隔开）
        measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
        upper_tolerance: 0.0, //上公差
        lower_tolerance: 0.0, //下公差
        standard_value: 0.0, //标准值
        measuring_frequency: '', //检测频次（是一个固定内容，查附录）
        department: '', //实施部门（是一个固定值，查附录）
        precision_hand: '',//手检/精测
        project_type: 0, //检测类型，和控制计划的关系（固定值，查附录）
        order_number: 0, //顺序号
        control_plan_id: 0 //控制计划关联号（记录控制计划id）
      },
      //主表的点击编辑类型
      tableDoe:0,
      //主表的点击行信息
      tableScope:null,

      //调整检测项目顺序的主表
      tableOrderData: [{
        id: null, // 主键
        create_time: null, // 创建时间
        update_time: null, // 修改时间
        creator: '', // 编辑人
        process_status:'',//流程状态
        sys_update_user:'',//更新人
        sys_audit_user:'',//审核人
        sys_audit_time:'',//审核时间
        sys_deleted: 0, //删除标记位 (0表示未删除)
        workshop: '', //车间名称三种语言（‘/’分割）
        drawing_number: '', //产品图号
        op: '', //工序号
        measuring_project: '', //检测项目名称（三种语言，用||隔开）
        measuring_requirement: '', //检测要求（三种语言，用||隔开）
        measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
        upper_tolerance: 0.0, //上公差
        lower_tolerance: 0.0, //下公差
        standard_value: 0.0, //标准值
        measuring_frequency: '', //检测频次（是一个固定内容，查附录）
        department: '', //实施部门（是一个固定值，查附录）
        precision_hand: '',//手检/精测
        project_type: 0, //检测类型，和控制计划的关系（固定值，查附录）
        order_number: 0, //顺序号
        control_plan_id: 0 //控制计划关联号（记录控制计划id）
      }],
      //调整检测项目顺序的表单控制
      tableOrderForm:{
        id: null, // 主键
        create_time: null, // 创建时间
        update_time: null, // 修改时间
        creator: '', // 编辑人
        process_status:'',//流程状态
        sys_update_user:'',//更新人
        sys_audit_user:'',//审核人
        sys_audit_time:'',//审核时间
        sys_deleted: 0, //删除标记位 (0表示未删除)
        workshop: '', //车间名称三种语言（‘/’分割）
        drawing_number: '', //产品图号
        op: '', //工序号
        measuring_project: '', //检测项目名称（三种语言，用||隔开）
        measuring_requirement: '', //检测要求（三种语言，用||隔开）
        measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
        upper_tolerance: 0.0, //上公差
        lower_tolerance: 0.0, //下公差
        standard_value: 0.0, //标准值
        measuring_frequency: '', //检测频次（是一个固定内容，查附录）
        department: '', //实施部门（是一个固定值，查附录）
        precision_hand: '',//手检/精测
        project_type: 0, //检测类型，和控制计划的关系（固定值，查附录）
        order_number: 0, //顺序号
        control_plan_id: 0 //控制计划关联号（记录控制计划id）
      },
      //调整检测项目顺序的点击编辑类型
      tableOrderDoe:0,
      //调整检测项目顺序的点击行信息
      tableOrderScope:null,

      //记录检测结果，用在用户录入界面；
      tableTest:[
        {
          id: null, // 主键
          create_time: null, // 创建时间
          update_time: null, // 修改时间
          creator: '', // 编辑人
          process_status:'',//流程状态
          sys_update_user:'',//更新人
          sys_audit_user:'',//审核人
          sys_audit_time:'',//审核时间
          sys_deleted: 0, //删除标记位 (0表示未删除)
          workshop: '', //车间名称三种语言（‘/’分割）
          drawing_number: '', //产品图号
          op: '', //工序号
          measuring_project: '', //检测项目名称（三种语言，用||隔开）
          measuring_requirement: '', //检测要求（三种语言，用||隔开）
          measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
          upper_tolerance: 0.0, //上公差
          lower_tolerance: 0.0, //下公差
          standard_value: 0.0, //标准值
          measuring_value:null,//测量值
          measuring_person:'',//检测人名称
          measuring_date:'',//检测时间
          measuring_shift:'',//检测班次
          part_number:'',//工件号
          is_ppk:'',//是否计算ppk
          no_calculate_reason:'',//不计算ppk原因
          measuring_project_id: '',//检测项目id
          precision_hand: '',//手检/精测
          isOk:'空'
        }
      ],
      tableTestForm:{
        id: null, // 主键
        create_time: null, // 创建时间
        update_time: null, // 修改时间
        creator: '', // 编辑人
        process_status:'',//流程状态
        sys_update_user:'',//更新人
        sys_audit_user:'',//审核人
        sys_audit_time:'',//审核时间
        sys_deleted: 0, //删除标记位 (0表示未删除)
        workshop: '', //车间名称三种语言（‘/’分割）
        drawing_number: '', //产品图号
        op: '', //工序号
        measuring_project: '', //检测项目名称（三种语言，用||隔开）
        measuring_requirement: '', //检测要求（三种语言，用||隔开）
        measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
        upper_tolerance: 0.0, //上公差
        lower_tolerance: 0.0, //下公差
        standard_value: 0.0, //标准值
        measuring_value:null,//测量值
        measuring_person:'',//检测人名称
        measuring_date:'',//检测时间
        measuring_shift:'',//检测班次
        part_number:'',//工件号
        is_ppk:'',//是否计算ppk
        no_calculate_reason:'',//不计算ppk原因
        measuring_project_id: '',//检测项目id
        precision_hand: '',//手检/精测
      },

      //记录检查结果，用在用户查询原始数据的界面；
      tableTestVal:[
        {
          id: null, // 主键
          create_time: null, // 创建时间
          update_time: null, // 修改时间
          creator: '', // 编辑人
          process_status:'',//流程状态
          sys_update_user:'',//更新人
          sys_audit_user:'',//审核人
          sys_audit_time:'',//审核时间
          sys_deleted: 0, //删除标记位 (0表示未删除)
          workshop: '', //车间名称三种语言（‘/’分割）
          drawing_number: '', //产品图号
          op: '', //工序号
          measuring_project: '', //检测项目名称（三种语言，用||隔开）
          measuring_requirement: '', //检测要求（三种语言，用||隔开）
          measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
          upper_tolerance: '', //上公差
          lower_tolerance:'', //下公差
          standard_value: '', //标准值
          measuring_value:null,//测量值
          measuring_person:'',//检测人名称
          measuring_date:'',//检测时间
          measuring_shift:'',//检测班次
          part_number:'',//工件号
          is_ppk:'',//是否计算ppk
          no_calculate_reason:'',//不计算ppk原因
          measuring_project_id: '',//检测项目id
          precision_hand: '',//手检/精测
        }
      ],
      tableTestValForm: {
          id: null, // 主键
          create_time: null, // 创建时间
          update_time: null, // 修改时间
          creator: '', // 编辑人
          process_status:'',//流程状态
          sys_update_user:'',//更新人
          sys_audit_user:'',//审核人
          sys_audit_time:'',//审核时间
          sys_deleted: 0, //删除标记位 (0表示未删除)
          workshop: '', //车间名称三种语言（‘/’分割）
          drawing_number: '', //产品图号
          op: '', //工序号
          measuring_project: '', //检测项目名称（三种语言，用||隔开）
          measuring_requirement: '', //检测要求（三种语言，用||隔开）
          measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
          upper_tolerance: '', //上公差
          lower_tolerance:'', //下公差
          standard_value: '', //标准值
          measuring_value:null,//测量值
          measuring_person:'',//检测人名称
          measuring_date:'',//检测时间
          measuring_shift:'',//检测班次
          part_number:'',//工件号
          is_ppk:'',//是否计算ppk
          no_calculate_reason:'',//不计算ppk原因
          measuring_project_id: '',//检测项目id
          precision_hand: '',//手检/精测
        },
      tableTestValDoe:0,
      tableTestValScope:null,

      //—————————————————————————————————————————————————————————————————————————————————
      //分页查询原始数据的变量
      measuringResultPagination: {
        currentPage: 1,
        pageSize: 50, // 每页显示条数
        total: 0,
      },

      //—————————————————————————————————————————————————————————————————————————————————
      //弹窗的控制变量
      //弹窗标题
      titleUse:'提示',
      //控制删除数据的弹窗,默认关闭
      deleteDataDialog:false,
      //编辑控制项目的弹窗
      tableFormDialog:false,
      //编辑检测项目的顺序的弹窗
      editOrderDialog:false,
      //控制检测结果编辑的弹窗
      measuringValueEditDialog:false,
      //控制是否计算ppk的弹窗
      ppkDialog:false,
      //控制连续六点上升/下降的弹窗
      continuousDataDialog:false,

      //—————————————————————————————————————————————————————————————————————————————————
      //选择器的变量
      testTypeOptions:testTypeOptions,//检测类型选择器变量
      frequencyOptions:frequencyOptions,//检测频次选择器变量
      departmentOptions:departmentOptions,//检测部门选择器变量
      precisionHandOptions:[
        {value:'精测/Precision measurement/Точное измерение',label:'精测/Precision measurement/Точное измерение'},
        {value:'手检/Hand inspection/Ручное осмотрение',label:'手检/Hand inspection/Ручное осмотрение'},
      ],
      workShiftOptions:[
        {value:'早班/morning Shift/Ранняя смена',label:'早班/morning Shift/Ранняя смена'},
        {value:'中班/middle shift/Средний класс',label:'中班/middle shift/Средний класс'},
        {value:'夜班/night shift/Ночная работа',label:'夜班/night shift/Ночная работа'},
      ],//生产班次选择器变量
      testProjectOptions:[
          {label:'',value:''}
      ],//所选工序的特性值选择器
      //是否计算ppk选择器变量
      isPpkOptions:[
        {value:'yes',label:'yes'},
        {value:'no',label:'no'},
      ],

      //其他的选择变量：
      measuring_project:'',//检测项目
      measuring_date:'',//检测日期
      part_number:'',//工件号，检测数据录入的中间变量
      measuring_person:'',
      measuring_shift:'',//记录班次选择器的变量
      filteredTableData: [], // 筛选后的数据

      testProject:null,//记录所选工序的特性名称

      //控制检测结果是否正确的变量
      circleColor:'black',

      //用在需要辅助输入内容的地方（检测项目新增/编辑的弹窗中）
      text1:'',
      text2:'',
      text3:'',
      text4:'',
      text5:'',
      text6:'',

      //—————————————————————————————————————————————————————————————————————————————————
      //趋势管理相关变量
      //按钮颜色变更
      chartBackground25:'#0269fa',
      chartColor25:'white',
      chartBackground50:'',
      chartColor50:'',
      chartBackground125:'',
      chartColor125:'',
      chartBackground300:'',
      chartColor300:'',
      chartBackground500:'',
      chartColor500:'',

      //原始数据画图时记录用户选择的是多少组数据
      clickQuantity:25,

      //记录用户点击趋势管理中某一行的内容，用作改变背景颜色
      measuringProjectRow:null,

      //图表的相关变量
      //折线图数据存放变量
      lineChartData:null,
      //直方图数据存放变量
      barChartData:null,
      //移动极差图数据存放变量
      movingRangeChartData:null,

      //连续六点上升/下降相关变量
      ppkResult:{},
      trendResult: {},
      continuousData:[
        {
          id: null, // 主键
          create_time: null, // 创建时间
          update_time: null, // 修改时间
          creator: '', // 编辑人
          process_status:'',//流程状态
          sys_update_user:'',//更新人
          sys_audit_user:'',//审核人
          sys_audit_time:'',//审核时间
          sys_deleted: 0, //删除标记位 (0表示未删除)
          workshop: '', //车间名称三种语言（‘/’分割）
          drawing_number: '', //产品图号
          op: '', //工序号
          measuring_project: '', //检测项目名称（三种语言，用||隔开）
          measuring_requirement: '', //检测要求（三种语言，用||隔开）
          measuring_type: '', //测量类型（是一个固定的内容：计量、计数、目视）
          upper_tolerance: '', //上公差
          lower_tolerance:'', //下公差
          standard_value: '', //标准值
          measuring_value:null,//测量值
          measuring_person:'',//检测人名称
          measuring_date:'',//检测时间
          measuring_shift:'',//检测班次
          part_number:'',//工件号
          is_ppk:'',//是否计算ppk
          no_calculate_reason:'',//不计算ppk原因
          measuring_project_id: '',//检测项目id
          precision_hand: '',//手检/精测
        }
      ],
    }
  },

  //—————————————————————————————————————————————————————————————————————————————————
  //—————————————————————————————————————————————————————————————————————————————————
  watch: {
    //监视导航筛选
    filterText(val) {
      this.$refs.tree.filter(val);
    },
  },

  //—————————————————————————————————————————————————————————————————————————————————
  //—————————————————————————————————————————————————————————————————————————————————
  methods: {
    //选择语言
    languageSelect(language){
      this.languageS=language
      this.componentKey = !this.componentKey;
      if (language==='chinese'){
        this.treeTesting=tree_amc_product_op_chinese
        this.treeTesting1=tree_amc_product_ops_chinese
        this.main.qualityManagementSystem='俄动力质量管理系统'
        this.main.processCapabilityMonitoring='过程能力监视系统'

        this.pageVal.ok='确定'
        this.pageVal.cancel='取消'
        this.pageVal.save='保存'
        this.pageVal.sureToDelete='确定删除数据吗？'
        this.pageVal.filter='输入关键字进行过滤'
        this.pageVal.measurementItem='检测项目'
        this.pageVal.add='新增'
        this.pageVal.measurementRequirement='检测要求'
        this.pageVal.measurementType='测量类型'
        this.pageVal.upperTolerance='上公差'
        this.pageVal.lowerTolerance='下公差'
        this.pageVal.standardValue='标准值'
        this.pageVal.measurementFrequency='检测频次'
        this.pageVal.department='实施部门'
        this.pageVal.precision_hand='精测/手检'
        this.pageVal.edit='编辑'

        this.pageVal.dataEntry='数据录入'
        this.pageVal.partNumber='工件号：'
        this.pageVal.measurementDate='检测日期：'
        this.pageVal.measurementPerson='测量人：'
        this.pageVal.shift='班次：'
        this.pageVal.select='请选择'
        this.pageVal.selectDate='选择日期'
        this.pageVal.uploadEXCEL='上传项目'
        this.pageVal.uploadBlock='上传报告(缸体)'
        this.pageVal.uploadHead='上传报告(缸盖)'
        this.pageVal.uploadHand='上传报告(手检)'
        this.pageVal.partNumber1='工件号'
        this.pageVal.measurementDate1='检测日期'
        this.pageVal.measurementPerson1='测量人'
        this.pageVal.shift1='班次'
        this.pageVal.actualValue='实测值'
        this.pageVal.assessment='判定'

        this.pageVal.workingInstrction='作业指导书'
        this.pageVal.trendManagement='趋势管理'
        this.pageVal.rawData='原始数据'
      }
      else if (language==='english'){
        this.treeTesting=tree_amc_product_op_english
        this.main.qualityManagementSystem='Quality Management System'
        this.main.processCapabilityMonitoring='Process Capability Monitoring'

        this.pageVal.ok='OK'
        this.pageVal.cancel='Cancel'
        this.pageVal.save='Save'
        this.pageVal.sureToDelete='Sure to delete the data?'
        this.pageVal.filter='Keywords for filtering'
        this.pageVal.measurementItem='Measurement Item'
        this.pageVal.add='Add'
        this.pageVal.measurementRequirement='Measurement Requirement'
        this.pageVal.measurementType='Measurement Type'
        this.pageVal.upperTolerance='Upper Tolerance'
        this.pageVal.lowerTolerance='Lower Tolerance'
        this.pageVal.standardValue='Standard Value'
        this.pageVal.measurementFrequency='Measurement Frequency'
        this.pageVal.department='Department'
        this.pageVal.precision_hand='Precision/ Hand inspection'
        this.pageVal.edit='Edit'

        this.pageVal.dataEntry='Data Entry'
        this.pageVal.partNumber='Part Number:'
        this.pageVal.measurementDate='Measurement Date:'
        this.pageVal.measurementPerson='Measurement Person:'
        this.pageVal.shift='Shift:'
        this.pageVal.select='Select'
        this.pageVal.selectDate='Select Date'
        this.pageVal.uploadEXCEL='Upload Project'
        this.pageVal.uploadBlock='Upload(Cylinder Block)'
        this.pageVal.uploadHead='Upload(Cylinder Head)'
        this.pageVal.uploadHand='Upload(Hand inspection)'
        this.pageVal.partNumber1='Part Number'
        this.pageVal.measurementDate1='Measurement Date'
        this.pageVal.measurementPerson1='Measurement Person'
        this.pageVal.shift1='Shift'
        this.pageVal.actualValue='Actual Value'
        this.pageVal.assessment='Assessment'

        this.pageVal.workingInstrction='Working Instrction'
        this.pageVal.trendManagement='Trend Management'
        this.pageVal.rawData='Raw Data'
      }
      else if (language==='russian'){
        this.treeTesting=tree_amc_product_op_russian
        this.main.qualityManagementSystem='Cистема yправления качества'
        this.main.processCapabilityMonitoring='Мониторинг потенциала процесса'

        this.pageVal.ok='Подтвердить'
        this.pageVal.cancel='Отмена'
        this.pageVal.save='Сохранить'
        this.pageVal.sureToDelete='Уверен в удалении данных?'
        this.pageVal.filter='Фильтр'
        this.pageVal.measurementItem='Показатель измерения'
        this.pageVal.add='Добавить'
        this.pageVal.measurementRequirement='Требования к измерению'
        this.pageVal.measurementType='Тип измерения'
        this.pageVal.upperTolerance='Верхняя толерантность'
        this.pageVal.lowerTolerance='Нижняя толерантность'
        this.pageVal.standardValue='Стандартное значение'
        this.pageVal.measurementFrequency='Частота измерения'
        this.pageVal.department='Департамент'
        this.pageVal.precision_hand='Точность/ ручное осмотрение'
        this.pageVal.edit='Редактировать'

        this.pageVal.dataEntry='Ввод данных'
        this.pageVal.partNumber='Номер детали:'
        this.pageVal.measurementDate='Дата измерения:'
        this.pageVal.measurementPerson='Человек измерения:'
        this.pageVal.shift='Перемещение:'
        this.pageVal.select='Выберите'
        this.pageVal.selectDate='Выберите дату'
        this.pageVal.uploadEXCEL='Загрузить проект'
        this.pageVal.uploadBlock='Загрузить(Cylinder Block)'
        this.pageVal.uploadHead='Загрузить(Cylinder Head)'
        this.pageVal.uploadHand='Загрузить(Ручное осмотрение)'
        this.pageVal.partNumber1='Номер детали'
        this.pageVal.measurementDate1='Дата измерения'
        this.pageVal.measurementPerson1='Человек измерения'
        this.pageVal.shift1='Перемещение'
        this.pageVal.actualValue='Фактическая стоимость'
        this.pageVal.assessment='Оценка'

        this.pageVal.workingInstrction='Рабочая инструкция'
        this.pageVal.trendManagement='Управление тенденциями'
        this.pageVal.rawData='Сырые данные'
      }
    },
    //退出登录
    logOut(){
      localStorage.removeItem('u_token');
      localStorage.removeItem('userName')
      this.$router.push('UserLogin')
    },
    //查询用户信息的函数
    inquiry(){
      //输入用户编号，向后端查询信息
      const useId=localStorage.getItem('userName').replace(/"/g, '');
      this.$request.post('/useQueryPower',{
        queryFiledName:'macTestCon',
        userId:useId,
      }).then(result=>{
        if (result.code === 401) {
          this.$router.push('UserLogin')
          alert("您未登录，请登录")
        }else {
          this.useName=result.data.name
          this.usePower=result.data.macTestCon
          this.useId=useId
        }
      })
    },
    // 通用，弹窗关闭的时候
    handleClose(done) {
      this.$confirm('确认关闭？')
          // eslint-disable-next-line no-unused-vars
          .then(_ => {
            done();
          })
          // eslint-disable-next-line no-unused-vars
          .catch(_ => {});
    },
    //通用：得到UUID的id数据
    generateUUIDv4() {
      const bytes = new Uint8Array(16);
      crypto.getRandomValues(bytes);

      // 设置版本位（第6字节的高4位为0100）
      bytes[6] = (bytes[6] & 0x0f) | 0x40;
      // 设置变体位（第8字节的高2位为10）
      bytes[8] = (bytes[8] & 0x3f) | 0x80;

      // 转换为32字符十六进制字符串
      return Array.from(bytes, byte => {
        return byte.toString(16).padStart(2, '0');
      }).join('');
    },
    // 通用，判断是不是数字的函数
    isNumber(value) {
      // 处理空值
      if (value === null || value === undefined || value === '') return false;
      // 去除首尾空格
      value = value.toString().trim();
      // 使用正则表达式检查是否是数字（包括正负数和小数）
      // const regex = /^-?\d+(\.\d+)?$/;
      const regex = /^[+-]?(\d+(\.\d*)?|\.\d+)$/;
      return regex.test(value);
    },
    //通用：保留指定位小数
    formatDecimal(value, decimals) {
      if (value === null || value === undefined) return '';
      return parseFloat(value).toFixed(decimals); // 保留指定位数小数
    },

    //—————————————————————————————————————————————————————————————————————————————————
    //在tab控件上单击的函数
    handleClick(tab, event) {
      console.log(tab, event,tab._props.name,tab.name);
      if (tab.name==='second'){
        //先把数据归零，然后再重新赋值
        this.tableTest=[]
        this.tableTest=_.cloneDeep(this.tableData)

        for (let i = 0; i < this.tableTest.length; i++) {
          this.tableTest[i].measuring_project_id=this.tableTest[i].id
          this.tableTest[i].isOk='空'
        }
      }
      //选择原始数据时，调用新的动态查询方法
      if (tab.name === 'rawData' && this.treeUseNode && this.treeUseNode.level === 3) {
        const baseConditions = this.getBaseConditions();
        // 重置分页到第一页
        this.measuringResultPagination.currentPage = 1;
        this.queryPrecisionMeasurementValue(baseConditions);
      }
    },
    //导航筛选的函数
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    //点击导航进行的筛选
    async treeClick(data, node) {
      this.treeUseOp = data.label;
      this.treeUseNode = node;

      if (this.treeUseNode.level===3){
        let fourData={
          firstFieldName: 'workshop',
          firstFieldVal: '机加车间/Machining workshop/Цех механической обработки',
          secondFieldName: 'drawing_number',
          secondFieldVal: node.parent.data.label,
          thirdName: 'op',
          thirdVal: data.label,
          fourthFieldName: 'precision_hand',
          fourthFiledVal:''
        }
        if (this.treeUseNode.parent.parent.data.label==='机加车间' || this.treeUseNode.parent.parent.data.label==='Machining workshop' || this.treeUseNode.parent.parent.data.label==='Цех механической обработки'){
          fourData.fourthFiledVal='精测/Precision measurement/Точное измерение'
        }
        else if (this.treeUseNode.parent.parent.data.label==='机加车间-手检' || this.treeUseNode.parent.parent.data.label==='Machining workshop-Hand inspection' || this.treeUseNode.parent.parent.data.label==='Цех механической обработки-Ручное осмотрение'){
          fourData.fourthFiledVal='手检/Hand inspection/Ручное осмотрение'
        }
        // 1. 先查询检测项目列表
        const projectResult = await this.$request.post('/precisionMeasProjectInquiryFourField', fourData);
        if (projectResult.code === 401) {
          this.$router.push('UserLogin');
          alert("您未登录，请登录");
          return; // 终止后续逻辑
        }

        // 2. 给大表赋值（原逻辑）
        this.tableData = projectResult.data;
        this.testProject = null;
        this.testProjectOptions = [];
        this.tableTest = _.cloneDeep(this.tableData);

        // 3. 同步给数据录入赋值
        for (let i = 0; i < this.tableTest.length; i++) {
          this.tableTest[i].measuring_project_id=this.tableTest[i].id
          //点击数据录入时，先默认给isOk字段赋值空，确保黑色圆圈显示
          this.tableTest[i].isOk='空'
          let testProject = { label: this.tableTest[i].project, value: this.tableTest[i].project };
          this.testProjectOptions.push(testProject);
        }

        // 4. 新增：如果当前在原始数据页面，调用新的动态查询方法
        if (this.activeName === 'rawData') {
          const baseConditions = {
            fieldName1: 'workshop',
            fieldValue1: fourData.firstFieldVal,
            fieldName2: 'drawing_number',
            fieldValue2: fourData.secondFieldVal,
            fieldName3: 'op',
            fieldValue3: fourData.thirdVal,
            fieldName4: 'precision_hand',
            fieldValue4: fourData.fourthFiledVal
          };

          // 重置分页到第一页
          this.measuringResultPagination.currentPage = 1;

          // 调用新的动态查询方法
          await this.queryPrecisionMeasurementValue(baseConditions);
        }

        //把趋势图中的图标进行清空
        if (this.barChartData) {
          this.barChartData.dispose()
        }
        if (this.lineChartData) {
          this.lineChartData.dispose()
        }
        if (this.movingRangeChartData) {
          this.movingRangeChartData.dispose()
        }
      }
    },

    //———————————————————————————————————————检测项目——————————————————————————————————————————
    //点击检测项目的弹窗,1:新增；2：编辑；3：删除
    tableShow(doe,scope){
      this.tableDoe=doe
      this.tableScope=scope
      if (this.treeUseNode===null || !this.treeUseNode.data.label.includes('OP')){
        if (this.languageS==='chinese'){
          this.$message.error('请选择工序后进行操作')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select a process before proceeding')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите операцию перед выполнением действий')
        }
        return
      }
      //是新增
      if (doe===1){
        //数据初始化
        this.tableForm={
              id: null, // 主键
              sys_deleted: 0, // 删除标记位 (假设0表示未删除)
              creator: this.useName, // 编辑人
              workshop:'机加车间/Machining workshop/Цех механической обработки', // 车间名称三种语言（‘/’分割）
              drawing_number: this.treeUseNode.parent.data.label, // 产品图号
              op: this.treeUseNode.data.label, // 工序号
              measuring_project: '', // 检测项目名称（三种语言，用||隔开）
              measuring_requirement: '', // 检测要求（三种语言，用||隔开）
              measuring_type: 1, // 测量类型（是一个固定的内容：计量、计数、目视）
              upper_tolerance: '', // 上公差
              lower_tolerance: '', // 下公差
              standard_value: '', // 标准值
              measuring_frequency: '', // 检测频次（是一个固定内容，查附录）
              department: '', // 实施部门（是一个固定值，查附录）
              precision_hand: '',
              project_type: 2, // 检测类型，和控制计划的关系（固定值，查附录）
              order_number: 0, // 顺序号
              control_plan_id: -1 // 控制计划关联号（记录控制计划id）
        }
        this.text1=''
        this.text2=''
        this.text3=''
        this.text4=''
        this.text5=''
        this.text6=''
        this.titleUse='您正在新建一条检查项目'
        this.tableFormDialog=true
      }
      //是编辑
      else if (doe===2){
        //赋值
        this.tableForm=_.cloneDeep(scope.row)
        this.text1=this.tableForm.measuring_project.split('|*|')[0]
        this.text2=this.tableForm.measuring_project.split('|*|')[1]
        this.text3=this.tableForm.measuring_project.split('|*|')[2]

        this.text4=this.tableForm.measuring_requirement.split('|*|')[0]
        this.text5=this.tableForm.measuring_requirement.split('|*|')[1]
        this.text6=this.tableForm.measuring_requirement.split('|*|')[2]

        this.titleUse='您正在修改一条检测项目'
        this.tableFormDialog=true
      }
      //对检测项目进行排序
      else if (doe===3){
        this.titleUse='您正在调整检测项目的顺序'
        this.tableOrderData=_.cloneDeep(this.tableData)
        this.editOrderDialog=true
      }
    },
    //对检测项目进行编辑、新增、删除等
    tableDataEdit(){
      //数据校验
      if (this.tableForm.department==='' || this.tableForm.department===null || this.tableForm.department===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请选择部门')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select a department')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите отдел')
        }
        return;
      }
      if (this.text1==='' || this.text1===null || this.text1===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入中文检测项目')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the Chinese inspection item')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите пункт проверки на китайском языке')
        }
        return
      }
      if (this.text2==='' || this.text2===null || this.text2===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入英文检测项目')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the English inspection item')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите пункт проверки на английском языке')
        }
        return;
      }
      if (this.text3==='' || this.text3===null || this.text3===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入俄文检测项目')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the Russian inspection item')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите пункт проверки на русском языке')
        }
        return;
      }
      if (this.text4==='' || this.text4===null || this.text4===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入中文检测要求')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the Chinese inspection requirement')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите требование проверки на китайском языке')
        }
        return;
      }
      if (this.text5==='' || this.text5===null || this.text5===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入英文检测要求')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the English inspection requirement')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите требование проверки на английском языке')
        }
        return;
      }
      if (this.text6==='' || this.text6===null || this.text6===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入俄文检测要求')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the Russian inspection requirement')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите требование проверки на русском языке')
        }
        return;
      }
      if (this.tableForm.precision_hand==='' || this.tableForm.precision_hand===null || this.tableForm.precision_hand===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请选择精测/手检')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please select precision measurement/manual inspection')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, выберите точное измерение/ручную проверку')
        }
        return;
      }
      if (this.tableForm.measuring_frequency==='' || this.tableForm.measuring_frequency===null || this.tableForm.measuring_frequency===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入检测频次')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the inspection frequency')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите частоту проверки')
        }
        return;
      }
      if (this.tableForm.upper_tolerance==='' || this.tableForm.upper_tolerance===null || this.tableForm.upper_tolerance===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入上公差')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the upper tolerance')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите верхний допуск')
        }
        return;
      }
      if (this.tableForm.lower_tolerance==='' || this.tableForm.lower_tolerance===null || this.tableForm.lower_tolerance===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入下公差')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the lower tolerance')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите нижний допуск')
        }
        return;
      }
      if (this.tableForm.standard_value==='' || this.tableForm.standard_value===null || this.tableForm.standard_value===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入标准值')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the standard value')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите стандартное значение')
        }
        return;
      }
      if (this.tableForm.upper_tolerance<=this.tableForm.lower_tolerance){
        if (this.languageS==='chinese'){
          this.$message.error('公差带范围异常，请核对')
        }
        else if (this.languageS==='english'){
          this.$message.error('Tolerance range is abnormal, please verify')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Диапазон допуска ненормальный, пожалуйста, проверьте')
        }
        return;
      }
       if (!this.isNumber(this.tableForm.standard_value)){
         if (this.languageS==='chinese'){
           this.$message.error('标准值非数字，请更改')
         }
         else if (this.languageS==='english'){
           this.$message.error('Standard value is not a number, please change')
         }
         else if (this.languageS==='russian'){
           this.$message.error('Стандартное значение не является числом, пожалуйста, измените')
         }
        return;
      }
      if (!this.isNumber(this.tableForm.upper_tolerance)){
        if (this.languageS==='chinese'){
          this.$message.error('上公差非数字，请更改')
        }
        else if (this.languageS==='english'){
          this.$message.error('Upper tolerance is not a number, please change')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Верхний допуск не является числом, пожалуйста, измените')
        }
        return;
      }
      if (!this.isNumber(this.tableForm.lower_tolerance)){
        if (this.languageS==='chinese'){
          this.$message.error('下公差非数字，请更正')
        }
        else if (this.languageS==='english'){
          this.$message.error('Lower tolerance is not a number, please change')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Нижний допуск не является числом, пожалуйста, измените')
        }
        return;
      }
      //组合数据
      this.tableForm.measuring_project=''
      this.tableForm.measuring_requirement=''
      this.tableForm.measuring_project=this.text1+'|*|'+this.text2+'|*|'+this.text3
      this.tableForm.measuring_requirement=this.text4+'|*|'+this.text5+'|*|'+this.text6
      //向后端写入数据
      //是新增
      if (this.tableDoe===1){
        this.$request.post('/precisionMeasProjectInsertOne',this.tableForm).then(result=>{
          if (result.code === 401) {
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }else {
            if (this.languageS==='chinese'){
              this.$message.success('插入成功')
            }
            else if (this.languageS==='english'){
              this.$message.success('Insert successfully')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Успешно вставить')
            }
            this.tableData.push(this.tableForm)
            this.tableFormDialog=false
          }
        })
      }
      //是修改
      else if (this.tableDoe===2){
        this.$request.post('/precisionMeasProjectEditOne',this.tableForm).then(result=>{
          if (result.code === 401) {
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }else {
            if (this.languageS==='chinese'){
              this.$message.success('编辑成功')
            }
            else if (this.languageS==='english'){
              this.$message.success('Edit successfully')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Редактировать успешно')
            }
            this.tableData.splice(this.tableScope.$index,1,this.tableForm)
            this.tableFormDialog=false
          }
        })
      }
    },

    //调整检测项目顺序
    editOrder(doe,scope){
      this.tableOrderScope=scope
      this.tableOrderDoe=doe
      if (doe===1){
        if(scope.$index===0){
          if (this.languageS==='chinese'){
            this.$message.warning("已经为项目第一条，无法上移")
          }
          else if (this.languageS==='english'){
            this.$message.warning('Already the first item, cannot move up')
          }
          else if (this.languageS==='russian'){
            this.$message.warning('Уже первый пункт, невозможно переместить вверх')
          }
        }
        else{
          this.tableOrderData.splice(scope.$index,1)
          this.tableOrderData.splice(scope.$index-1,0,scope.row)
        }
      }
      else if (doe===2){
        if(scope.$index===this.tableOrderData.length-1){
          if (this.languageS==='chinese'){
            this.$message.warning("已经为项目最后一条，无法上移")
          }
          else if (this.languageS==='english'){
            this.$message.warning('Already the last item, cannot move down')
          }
          else if (this.languageS==='russian'){
            this.$message.warning('Уже последний пункт, невозможно переместить вниз')
          }
        }
        else{
          this.tableOrderData.splice(scope.$index,1)
          this.tableOrderData.splice(scope.$index+1,0,scope.row)
        }
      }
    },
    //调整检测项目顺序后向后端修改
    editOrderOk(){
      for (let i = 0; i < this.tableOrderData.length; i++) {
        this.tableOrderData[i].order_number=i
      }
      this.$request.post('/editProjectOrderMacTestCon',this.tableOrderData).then(result=>{
        if (result.code === 401) {
          this.$router.push('UserLogin')
          alert("您未登录，请登录")
        }
        else {
          this.tableData=this.tableOrderData
          this.editOrderDialog=false
        }
      })
    },

    //————————————————————————————————————————数据录入—————————————————————————————————————————
    //当测量人失去焦点的时候，触发的函数：赋值给下方表格中的工件号
    measuringPersonEdit(){
      for (let i = 0; i < this.tableTest.length; i++) {
        this.$set(this.tableTest, i, { ...this.tableTest[i], measuring_person: this.measuring_person });
      }
    },
    //当工件号失去焦点的时候，触发的函数：赋值给下方表格中的工件号
    partNumEdit(){
      for (let i = 0; i < this.tableTest.length; i++) {
         this.$set(this.tableTest, i, { ...this.tableTest[i], part_number: this.part_number });
      }
    },
    //当检测日期失去焦点的时候，触发的函数：赋值给下方表格中的检测日期
    measuringDateEdit(){
      for (let i = 0; i < this.tableTest.length; i++) {
        this.$set(this.tableTest, i, { ...this.tableTest[i], measuring_date: this.measuring_date });
      }
    },
    //当班次失去焦点的时候，触发的函数：赋值给下方表格中的检测班次
    workShiftEdit(){
      for (let i = 0; i < this.tableTest.length; i++) {
        this.$set(this.tableTest, i, { ...this.tableTest[i], measuring_shift: this.measuring_shift });
      }
    },

    //当用户输好一个测量值以后，判断是否合格
    testValEdit(scope){
      //判断数字是否非法
      if (scope.measuring_value===''){
        return '空';
      }
      if (!this.isNumber(scope.measuring_value)){
        if (this.languageS==='chinese'){
          this.$message.error('点检值非数值，请修改')
        }
        else if (this.languageS==='english'){
          this.$message.error('The check value is not a numerical value, please modify it')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Значение проверки не является цифровым значением, пожалуйста, измените его')
        }
        return;
      }
      if (Number(scope.measuring_value) < Number(Number(scope.standard_value) + Number(scope.lower_tolerance)) ||
          Number(scope.measuring_value) > Number(Number(scope.standard_value) + Number(scope.upper_tolerance))){
        if (this.languageS==='chinese'){
          this.$message.warning("不合格项目："+ scope.measuring_project)
        }
        else if (this.languageS==='english'){
          this.$message.warning("Non-conforming items:"+ scope.measuring_project)
        }
        else if (this.languageS==='russian'){
          this.$message.warning("Несоответствующие пункты:"+ scope.measuring_project)
        }
        return '否'
      }
      else {
        return '是'
      }
    },
    testValEditHand(scope){
      this.tableTest[scope.$index].isOk=this.testValEdit(scope.row)
    },
    //点击保存输入的检测数据
    tableTestSave() {
      let temp=_.cloneDeep(this.tableTest)
      // 1. 为每条记录添加 is_ppk 字段并赋值为 "yes"
      temp.forEach(item => {item.is_ppk = "yes"; });

      //将不合格检测项目计入可疑品清单
      let suspectListShowForm= {
            //主键
            id: '',
            //创建时间
            create_time: '',
            //更新时间
            update_time: '',
            //创建人
            creator: '',
            //流程状态
            process_status: '',
            //更新人
            sys_update_user: '',
            //审核人
            sys_audit_user: '',
            //审核时间
            sys_audit_time: '',
            //逻辑删除
            sys_deleted: '',
            //零部件名称
            part_name: '',
            //零部件供方
            part_supplier: '',
            //型号
            model_id: '',
            //发生时间
            occur_date: '',
            //发生环节
            link: '',
            //发现工序
            position: '',
            //发现人
            occur_per: '',
            //工件号
            part_id: '',
            //问题描述
            describe_use: '',
            //发生数量
            part_num: '',
            //可疑品判定
            judgement: '',
            //追溯判定
            from_judgment: '',
            //追溯过程
            from_process: '',
            //不良品处理
            unqualified: '',
            //返工返修
            rework: '',
            //自有系统主键
            idUse: '',
            //自有编辑人
            editor: '',
            //自有创建时间
            establishTime: '',
            //自有修改时间
            updateTime: '',
            //问题解决
            solve: ''
          }
      //记录此工件有几项不合格项
      let unqualifiedItem=0
      //记录不合格信息描述
      let unqualifiedDescription=''
      for (let i = 0; i < temp.length; i++) {
        if (temp[i].isOk==='否'){
          unqualifiedItem = unqualifiedItem+1
          // unqualifiedDescription =
          //     unqualifiedDescription +
          //     "Project:" + temp[i].measuring_project + "," +
          //     "Requirement:" + temp[i].measuring_requirement + "," +
          //     "Value:" + temp[i].measuring_value + ";"
          // 解析多语言字段
          const chineseProject = temp[i].measuring_project.split('|*|')[0];
          const englishProject = temp[i].measuring_project.split('|*|')[1];
          const russianProject = temp[i].measuring_project.split('|*|')[2];

          const chineseRequirement = temp[i].measuring_requirement.split('|*|')[0];
          const englishRequirement = temp[i].measuring_requirement.split('|*|')[1];
          const russianRequirement = temp[i].measuring_requirement.split('|*|')[2];

          const value = temp[i].measuring_value;

          // 构建三种语言的描述
          const chineseDesc = `Project:${chineseProject},Requirement:${chineseRequirement},Value:${value}`;
          const englishDesc = `Project:${englishProject},Requirement:${englishRequirement},Value:${value}`;
          const russianDesc = `Project:${russianProject},Requirement:${russianRequirement},Value:${value}`;

          // 用 / 连接
          unqualifiedDescription = unqualifiedDescription +
              chineseDesc + '/' + russianDesc + '/' + englishDesc + ';';
        }
      }
      if (unqualifiedItem>0){
        let partName=''
        if (this.treeUseNode.parent.data.label==='1002100XEB75'){
          partName='1002100XEB75' + '/' + '气缸体组件' + '/' + 'Cylinder Block Comb' + '/' + 'Блок Цилиндров В Сборе'
        }
        else if(this.treeUseNode.parent.data.label==='1003100AEB75'){
          partName='1003100AEB75' + '/' + '气缸盖总成' + '/' + 'Cylinder Head Assy' + '/' + 'Головка Блока Цилиндров В Сборе'
        }
        suspectListShowForm= {
          //主键
          id: this.generateUUIDv4(),
          //创建时间
          create_time: '',
          //更新时间
          update_time: '',
          //创建人
          creator: 'AI检验员-机加',
          //流程状态
          process_status: '',
          //更新人
          sys_update_user: 'AI检验员-机加',
          //审核人
          sys_audit_user: '',
          //审核时间
          sys_audit_time: '',
          //逻辑删除
          sys_deleted: 0,
          //零部件名称
          part_name: partName,
          //零部件供方
          part_supplier: '自制件',
          //型号
          model_id: 'EB75',
          //发生时间
          occur_date: temp[0].measuring_date,
          //发生环节
          link: '机加/Machining Workshop/Обработки линия',
          //发现工序
          position: temp[0].op,
          //发现人
          occur_per: temp[0].measuring_person,
          //工件号
          part_id: temp[0].part_number,
          //问题描述
          describe_use: unqualifiedDescription,
          //发生数量
          part_num: 1,
          //可疑品判定
          judgement: '',
          //追溯判定
          from_judgment: '',
          //追溯过程
          from_process: '',
          //不良品处理
          unqualified: '',
          //返工返修
          rework: '',
          //自有系统主键
          idUse: '',
          //自有编辑人
          editor: '',
          //自有创建时间
          establishTime: '',
          //自有修改时间
          updateTime: '',
          //问题解决
          solve: ''
        }
      }
      // 2. 遍历所有行，进行数据校验
      for (let i = 0; i < temp.length; i++) {
        if(temp[i].measuring_value==='' ||temp[i].measuring_value===undefined || temp[i].measuring_value===null){
          temp.splice(i, 1)
        }
        else{
          //校验测量值是否为数值
          if (this.isNumber(temp[i].measuring_value)){
            //校验检测日期是否为空
            if (temp[i].measuring_date==='' || temp[i].measuring_date===undefined || temp[i].measuring_date===null){
              if (this.languageS==='chinese'){
                this.$message.warning(`第 ${i + 1} 行：检测日期未填写`)
              }
              else if (this.languageS==='english'){
                this.$message.warning(`Row ${i + 1}: Inspection date not filled`)
              }
              else if (this.languageS==='russian'){
                this.$message.warning(`Строка ${i + 1}: Дата проверки не заполнена`)
              }
              return;
            }
            else{
              //校验工件号是否为空
              if(temp[i].part_number==='' || temp[i].part_number===undefined ||temp[i].part_number===null){
                if (this.languageS==='chinese'){
                  this.$message.warning(`第 ${i + 1} 行：工件号未填写`)
                }
                else if (this.languageS==='english'){
                  this.$message.warning(`Row ${i + 1}: Workpiece number not filled`)
                }
                else if (this.languageS==='russian'){
                  this.$message.warning(`Строка ${i + 1}: Номер детали не заполнен`)
                }
                return;
              }
              //校验检测班次是否为空
              else {
                if (temp[i].measuring_shift==='' || temp[i].measuring_shift===undefined || temp[i].measuring_shift===null){
                  if (this.languageS==='chinese'){
                    this.$message.warning(`第 ${i + 1} 行：检测班次未填写`)
                  }
                  else if (this.languageS==='english'){
                    this.$message.warning(`Row ${i + 1}: Inspection shift not filled`)
                  }
                  else if (this.languageS==='russian'){
                    this.$message.warning(`Строка ${i + 1}: Смена проверки не заполнена`)
                  }
                  return;
                }
                //校验测量人是否为空
                else{
                  if(temp[i].measuring_person==='' || temp[i].measuring_person===undefined || temp[i].measuring_person===null){
                    if (this.languageS==='chinese'){
                      this.$message.warning(`第 ${i + 1} 行：测量人未填写`)
                    }
                    else if (this.languageS==='english'){
                      this.$message.warning(`Row ${i + 1}: Measurer not filled`)
                    }
                    else if (this.languageS==='russian'){
                      this.$message.warning(`Строка ${i + 1}: Измеритель не заполнен`)
                    }
                    return;
                  }
                }
              }
            }
          }
        }
      }
      // 3. 如果校验通过，提交数据
      this.$request.post('/testValPrecisionMeasProject', temp).then(result => {
          if (result.code === 401) {
            this.$router.push('UserLogin');
            this.$message.error("您未登录，请登录");
          } else if (result.data === '保存成功') {
            if (this.languageS==='chinese'){
              this.$message.success('保存成功');
            }
            else if (this.languageS==='english'){
              this.$message.success('Save successful')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Сохранить успешно')
            }

            //把不合格的检测项目计入不合格品清单
            this.$request.post('/insertOneSuspectProductListMacTestCon', suspectListShowForm).then(result=>{
            return result.data;
            })
          } else {
            if (this.languageS==='chinese'){
              this.$message.error('保存失败，请联系管理员');
            }
            else if (this.languageS==='english'){
              this.$message.error('Save failed, please contact administrator')
            }
            else if (this.languageS==='russian'){
              this.$message.error('Сохранение не удалось, пожалуйста, свяжитесь с администратором')
            }
          }
        });

      // 4. 清空表格数据
      this.tableTest.forEach(item => {
          item.measuring_value = '';
          item.measuring_person = '';
          item.measuring_shift = '';
          item.measuring_date = '';
          item.part_number = '';
        });

      // 5. 清空表单选择器
      this.part_number = '';
      this.measuring_date = '';
      this.measuring_person = '';
      this.measuring_shift = '';
    },

    //上传EXCEL文件成功的函数
    //eslint-disable-next-line no-unused-vars
    handleUploadSuccess(file, fileList) {
      // 处理上传成功逻辑
      const fileToRead = file.raw || null; // 使用可选链操作符来安全地访问 raw 属性
      if (!fileToRead) return;
      const reader = new FileReader();
      reader.onload = (e) => {
        //组合成Json格式
        const data = new Uint8Array(e.target.result);
        const workbook = XLSX.read(data, { type: 'array' });
        const firstSheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[firstSheetName];
        const jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
        //组合数据
        let tableData=[]
        //得到工序号
        let op
        if (jsonData[0][0].split('-').length===3){
          op=jsonData[0][0].split('-')[1]+'-'+jsonData[0][0].split('-')[2]
        }
        else {
          op=jsonData[0][0].split('-')[1]
        }
        //找到图号
        let drawing_number
        if (jsonData[0][0].includes('缸体')){
          drawing_number='1002100XEB75'
        }
        else if (jsonData[0][0].includes('缸盖')){
          drawing_number='1003100AEB75'
        }

        for (let i = 3; i < jsonData.length; i++) {
          //匹配组合检测要求
          let requirement
          if (jsonData[i][4]===0 && jsonData[i][6]===0){
            requirement='≤'+String(jsonData[i][5])+'|*|'+'≤'+String(jsonData[i][5])+'|*|'+'≤'+String(jsonData[i][5])
          }
          else {
            requirement=String(jsonData[i][6])+'≤'+ String(jsonData[i][4])+'≤'+String(jsonData[i][5])+'|*|'+String(jsonData[i][6])+'≤'+ String(jsonData[i][4])+'≤'+String(jsonData[i][5])+'|*|'+String(jsonData[i][6])+'≤'+ String(jsonData[i][4])+'≤'+String(jsonData[i][5])
          }
          //精测/手检
          let method
          if((this.usePower===1 || this.usePower==='1') &&(this.treeUseNode?.parent?.parent?.data?.label==='机加车间' || this.treeUseNode?.parent?.parent?.data?.label==='Machining workshop' || this.treeUseNode?.parent?.parent?.data?.label==='Цех механической обработки')){
            method='精测/Precision measurement/Точное измерение'
          }
          else if((this.usePower===1 || this.usePower==='1') &&(this.treeUseNode?.parent?.parent?.data?.label==='机加车间-手检' || this.treeUseNode?.parent?.parent?.data?.label==='Machining workshop-Hand inspection' || this.treeUseNode?.parent?.parent?.data?.label==='Цех механической обработки-Ручное осмотрение')){
            method='手检/Hand inspection/Ручное осмотрение'
          }

          let tableForm={
            id: null, // 主键
            create_time: null, // 创建时间
            update_time: null, // 修改时间
            sys_deleted: 0, // 删除标记位 (0表示未删除)
            creator: '', // 编辑人
            workshop: '机加车间/Machining workshop/Цех механической обработки', // 车间名称三种语言（‘/’分割）
            drawing_number: drawing_number, // 产品图号
            op: op, // 工序号
            measuring_project: jsonData[i][0]+'|*|'+jsonData[i][1]+'|*|'+jsonData[i][2], // 检测项目名称（三种语言，用|*|隔开）
            measuring_requirement: requirement, // 检测要求（三种语言，用|*|隔开）
            measuring_type: 1, // 测量类型（是一个固定的内容：计量、计数、目视）
            upper_tolerance: jsonData[i][5], // 上公差
            lower_tolerance: jsonData[i][6], // 下公差
            standard_value: jsonData[i][4], // 标准值
            measuring_frequency: 9, // 检测频次（是一个固定内容，查附录）
            department: '品质管理科/Quality Management Department/Секция управления качеством', // 实施部门（是一个固定值，查附录）
            project_type: 2, // 检测类型，和控制计划的关系（固定值，查附录）
            order_number: i-2, // 顺序号
            control_plan_id: -1, // 控制计划关联号（记录控制计划id）
            precision_hand: method
          }
          tableData.push(tableForm)
        }
        //向后端批量的插入
        this.$request.post('/insertTableDataListPrecisionMeasProject',tableData).then(result=>{
          if (result.code === 401) {
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }else {
            this.$message.success(result.data)
          }
        })
      };
      reader.readAsArrayBuffer(fileToRead);
      if (this.languageS==='chinese'){
        this.$message.success('文件上传成功')
      }
      else if (this.languageS==='english'){
        this.$message.success('File upload successful')
      }
      else if (this.languageS==='russian'){
        this.$message.success('Загрузка файла успешна')
      }
      // 清空已选文件列表
      this.$refs.excelUpload.clearFiles();
    },
    //上传EXCEL文件失败的函数
    handleUploadError(err, file, fileList) {
      // 处理上传失败逻辑
      console.error('上传失败:', err,file,fileList)
      if (this.languageS==='chinese'){
        this.$message.error('文件上传失败')
      }
      else if (this.languageS==='english'){
        this.$message.error('File upload failed')
      }
      else if (this.languageS==='russian'){
        this.$message.error('Загрузка файла не удалась')
      }
    },

    //上传数据成功 GG
    //eslint-disable-next-line no-unused-vars
    handleUploadDataSuccess(file, fileList) {
      // 获取文件名
      const fileName = file.name; // 这是获取文件名的方式
      const nameWithoutExt = fileName.replace(/\.(xlsx|xls)$/, '');
      // 处理上传成功逻辑
      const fileToRead = file.raw || null; // 使用可选链操作符来安全地访问 raw 属性
      if (!fileToRead) return;
      const reader = new FileReader();
      reader.onload = (e) => {
        //组合成Json格式
        const data = new Uint8Array(e.target.result);
        const workbook = XLSX.read(data, {type: 'array'});
        const firstSheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[firstSheetName];
        const jsonData = XLSX.utils.sheet_to_json(worksheet, {header: 1});
        console.log(jsonData)
        //找到图号
        let drawing_number
        if (fileName.split('-')[1]==='Cylinder Head'){
          drawing_number='1003100AEB75'
        }
        //得到工序号
        let op
        if (fileName.split('-').length===5){
          if (nameWithoutExt.split('-')[4]==='1'){
            op=nameWithoutExt.split('-')[2]+'-'+nameWithoutExt.split('-')[4]
          }
          else if (nameWithoutExt.split('-')[4]==='2'){
            op=nameWithoutExt.split('-')[2]+'-'+nameWithoutExt.split('-')[4]
          }
          else if (nameWithoutExt.split('-')[4]==='A1'){
            op=nameWithoutExt.split('-')[2]+'A'+'-'+'1'
          }
          else if (nameWithoutExt.split('-')[4]==='A2'){
            op = nameWithoutExt.split('-')[2] + 'A' + '-' + '2';
          }
          else if (nameWithoutExt.split('-')[4]==='B1'){
            op=nameWithoutExt.split('-')[2]+'B'+'-'+'1'
          }
          else if (nameWithoutExt.split('-')[4]==='B2'){
            op=nameWithoutExt.split('-')[2]+'B'+'-'+'2'
          }
          else {
            op=nameWithoutExt.split('-')[2]
          }
          //查询出所有检测项目(通过车间、图号、工序查找)
          this.$request.post('/precisionMeasProjectInquiryThreeField',{
            firstFieldName:'workshop',
            firstFieldVal:'机加车间/Machining workshop/Цех механической обработки',
            secondFieldName:'drawing_number',
            secondFieldVal:drawing_number,
            thirdName:'op',
            thirdVal:op
          }).then(
              result=>{
                if (result.code === 401) {
                  this.$router.push('UserLogin')
                  alert("您未登录，请登录")}
                else {
                  let filterResult = []
                  for (let i = 0; i < result.data.length; i++) {
                    let temp = result.data[i].measuring_project.split('|*|')[0]
                    //filterResult是筛出来中文检测项目
                    for (let j = 0; j < jsonData.length; j++) {
                      //after是组合X、Y、Z后的中文检测项目
                      let after
                      after = jsonData[j][0] + "-" + jsonData[j][3]
                      if (after === temp) {
                        let resultForm = {
                          id: null, // 主键
                          create_time: null, // 创建时间
                          update_time: null, // 修改时间
                          creator: this.useName, // 编辑人
                          process_status: '',//流程状态
                          sys_update_user: '',//更新人
                          sys_audit_user: '',//审核人
                          sys_audit_time: '',//审核时间
                          sys_deleted: 0, //删除标记位 (0表示未删除)
                          workshop: '机加车间/Machining workshop/Цех механической обработки', //车间名称三种语言（‘/’分割）
                          drawing_number: result.data[i].drawing_number, //产品图号
                          op: result.data[i].op, //工序号
                          measuring_project: result.data[i].measuring_project, //检测项目名称（三种语言，用||隔开）
                          measuring_requirement: result.data[i].measuring_requirement, //检测要求（三种语言，用||隔开）
                          measuring_type: result.data[i].measuring_type, //测量类型（是一个固定的内容：计量、计数、目视）
                          upper_tolerance: result.data[i].upper_tolerance, //上公差
                          lower_tolerance: result.data[i].lower_tolerance, //下公差
                          standard_value: result.data[i].standard_value, //标准值
                          measuring_value: jsonData[j][6],//测量值
                          measuring_person: jsonData[2][1],//检测人名称
                          measuring_date: this.measuring_date,//检测时间
                          measuring_shift: this.measuring_shift,//检测班次
                          part_number: jsonData[3][1],//工件号
                          is_ppk: 'yes',//是否计算ppk
                          no_calculate_reason: '',//不计算ppk原因
                          measuring_project_id: result.data[i].id,//关联检测项目id
                          precision_hand: '精测/Precision measurement/Точное измерение'//精测
                        }
                        filterResult.push(resultForm)
                      }
                    }
                  }
                  //循环查重
                  const noFilterResult = filterResult.filter((obj, index, self) =>
                      index === self.findIndex((t) => (
                              t.measuring_project === obj.measuring_project
                          )
                      ))
                  console.log(noFilterResult)
                  console.log(result.data)
                  const findDifferences = (arr1, arr2, key) => {
                    const map1 = new Map(arr1.map(item => [item[key], item]));
                    const map2 = new Map(arr2.map(item => [item[key], item]));

                    const diff1 = arr1.filter(item => !map2.has(item[key]));
                    const diff2 = arr2.filter(item => !map1.has(item[key]));

                    return { onlyInArr1: diff1, onlyInArr2: diff2 };
                  };

                  const differences = findDifferences(noFilterResult, result.data, 'measuring_project'); // 假设用id属性比较
                  console.log('差异项:', differences);

                  //将组合好的数据赋值给大表
                  this.tableTest=filterResult;
                  //给判定的圆圈赋值
                  for (let i = 0; i < this.tableTest.length; i++) {
                    this.tableTest[i].isOk=this.testValEdit(this.tableTest[i])
                  }
                }
              }
          )
        }
        else if (fileName.split('-').length===6){
          if (nameWithoutExt.split('-')[4]==='1'){
            op=nameWithoutExt.split('-')[2]+'-'+nameWithoutExt.split('-')[4]
          }
          else if (nameWithoutExt.split('-')[4]==='2'){
            op=nameWithoutExt.split('-')[2]+'-'+nameWithoutExt.split('-')[4]
          }
          else if (nameWithoutExt.split('-')[4]==='A1'){
            op=nameWithoutExt.split('-')[2]+'A'+'-'+'1'
          }
          else if (nameWithoutExt.split('-')[4]==='A2'){
            op = nameWithoutExt.split('-')[2] + 'A' + '-' + '2';
          }
          else if (nameWithoutExt.split('-')[4]==='B1'){
            op=nameWithoutExt.split('-')[2]+'B'+'-'+'1'
          }
          else if (nameWithoutExt.split('-')[4]==='B2'){
            op=nameWithoutExt.split('-')[2]+'B'+'-'+'2'
          }
          else {
            op=nameWithoutExt.split('-')[2]
          }
          //查询出所有检测项目(通过车间、图号、工序查找)
          this.$request.post('/precisionMeasProjectInquiryThreeField',{
            firstFieldName:'workshop',
            firstFieldVal:'机加车间/Machining workshop/Цех механической обработки',
            secondFieldName:'drawing_number',
            secondFieldVal:drawing_number,
            thirdName:'op',
            thirdVal:op
          }).then(
              result=>{
                if (result.code === 401) {
                  this.$router.push('UserLogin')
                  alert("您未登录，请登录")}
                else {
                  let filterResult = []
                  for (let i = 0; i < result.data.length; i++) {
                    let temp = result.data[i].measuring_project.split('|*|')[0]
                    //filterResult是筛出来中文检测项目
                    for (let j = 0; j < jsonData.length; j++) {
                      //after是组合X、Y、Z后的中文检测项目
                      let after
                      after = jsonData[j][0] + "-" + jsonData[j][3]
                      if (after === temp) {
                        let resultForm = {
                          id: null, // 主键
                          create_time: null, // 创建时间
                          update_time: null, // 修改时间
                          creator: this.useName, // 编辑人
                          process_status: '',//流程状态
                          sys_update_user: '',//更新人
                          sys_audit_user: '',//审核人
                          sys_audit_time: '',//审核时间
                          sys_deleted: 0, //删除标记位 (0表示未删除)
                          workshop: '机加车间/Machining workshop/Цех механической обработки', //车间名称三种语言（‘/’分割）
                          drawing_number: result.data[i].drawing_number, //产品图号
                          op: result.data[i].op, //工序号
                          measuring_project: result.data[i].measuring_project, //检测项目名称（三种语言，用||隔开）
                          measuring_requirement: result.data[i].measuring_requirement, //检测要求（三种语言，用||隔开）
                          measuring_type: result.data[i].measuring_type, //测量类型（是一个固定的内容：计量、计数、目视）
                          upper_tolerance: result.data[i].upper_tolerance, //上公差
                          lower_tolerance: result.data[i].lower_tolerance, //下公差
                          standard_value: result.data[i].standard_value, //标准值
                          measuring_value: jsonData[j][6],//测量值
                          measuring_person: jsonData[2][1],//检测人名称
                          measuring_date: this.measuring_date,//检测时间
                          measuring_shift: this.measuring_shift,//检测班次
                          part_number: jsonData[3][1],//工件号
                          is_ppk: 'yes',//是否计算ppk
                          no_calculate_reason: '',//不计算ppk原因
                          measuring_project_id: result.data[i].id,//关联检测项目id
                          precision_hand: '精测/Precision measurement/Точное измерение'//精测
                        }
                        filterResult.push(resultForm)
                      }
                    }
                  }
                  //循环查重
                  const noFilterResult = filterResult.filter((obj, index, self) =>
                      index === self.findIndex((t) => (
                              t.measuring_project === obj.measuring_project
                          )
                      ))
                  console.log(noFilterResult)
                  console.log(result.data)
                  const findDifferences = (arr1, arr2, key) => {
                    const map1 = new Map(arr1.map(item => [item[key], item]));
                    const map2 = new Map(arr2.map(item => [item[key], item]));

                    const diff1 = arr1.filter(item => !map2.has(item[key]));
                    const diff2 = arr2.filter(item => !map1.has(item[key]));

                    return { onlyInArr1: diff1, onlyInArr2: diff2 };
                  };

                  const differences = findDifferences(noFilterResult, result.data, 'measuring_project'); // 假设用id属性比较
                  console.log('差异项:', differences);

                  //将组合好的数据赋值给大表
                  this.tableTest=filterResult;
                  //给判定的圆圈赋值
                  for (let i = 0; i < this.tableTest.length; i++) {
                    this.tableTest[i].isOk=this.testValEdit(this.tableTest[i])
                  }
                }
              }
          )
        }
      }
      reader.readAsArrayBuffer(fileToRead);
      if (this.languageS==='chinese'){
        this.$message.success('文件上传成功')
      }
      else if (this.languageS==='english'){
        this.$message.success('File upload successful')
      }
      else if (this.languageS==='russian'){
        this.$message.success('Загрузка файла успешна')
      }
      // 清空已选文件列表
      this.$refs.excelUpload.clearFiles();
    },

    //上传数据成功 GT
    //eslint-disable-next-line no-unused-vars
    handleUploadDataSuccessGT(file, fileList) {
      // 获取文件名
      const fileName = file.name; // 这是获取文件名的方式
      // 提取 measuring_person（去掉 .xlsx）
      const nameWithoutExt = fileName.replace(/\.(xlsx|xls)$/, '');
      const measuring_person = nameWithoutExt.split('-').pop();
      // 处理上传成功逻辑
      const fileToRead = file.raw || null; // 使用可选链操作符来安全地访问 raw 属性
      if (!fileToRead) return;
      const reader = new FileReader();
      reader.onload = (e) => {
        //组合成Json格式
        const data = new Uint8Array(e.target.result);
        const workbook = XLSX.read(data, {type: 'array'});
        const firstSheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[firstSheetName];
        const jsonData = XLSX.utils.sheet_to_json(worksheet, {header: 1});
        //找到图号
        let drawing_number
        if (fileName.split('-')[1]==='Cylinder Block'){
          drawing_number='1002100XEB75'
        }
        else if(fileName.split('-')[1]==='Cylinder Head'){
          drawing_number='1003100AEB75'
        }
        // 确定工序号
        const fileNameParts = fileName.split('-');
        let op = '';
        let partNumber = '';

        if (fileNameParts.length === 6) {
          if (fileName.includes('-1') || fileName.includes('-2')) {
            op = fileNameParts[2] + '-' + fileNameParts[4];
          }
          partNumber = fileNameParts[3];
        }
        else if (fileNameParts.length === 5) {
          op = fileNameParts[2];
          partNumber = fileNameParts[3];
        }
        this.$request.post('/precisionMeasProjectInquiryThreeField',{
          firstFieldName:'workshop',
          firstFieldVal:'机加车间/Machining workshop/Цех механической обработки',
          secondFieldName:'drawing_number',
          secondFieldVal:drawing_number,
          thirdName:'op',
          thirdVal:op
        }).then(
            result=>{
              if (result.code === 401) {
                this.$router.push('UserLogin')
                alert("您未登录，请登录")
              }
              else {
                let filterResult = []
                console.log(result.data)
                for (let i = 0; i < result.data.length; i++) {
                  let temp = result.data[i].measuring_project.split('|*|')[0]
                  //filterResult是筛出来中文检测项目
                  for (let j = 0; j < jsonData.length; j++) {
                    let after
                    after = jsonData[j][0]
                    if (after === temp) {
                      let resultForm = {
                        id: null, // 主键
                        create_time: null, // 创建时间
                        update_time: null, // 修改时间
                        creator: this.useName, // 编辑人
                        process_status: '',//流程状态
                        sys_update_user: '',//更新人
                        sys_audit_user: '',//审核人
                        sys_audit_time: '',//审核时间
                        sys_deleted: 0, //删除标记位 (0表示未删除)
                        workshop: '机加车间/Machining workshop/Цех механической обработки', //车间名称三种语言（‘/’分割）
                        drawing_number: result.data[i].drawing_number, //产品图号
                        op: result.data[i].op, //工序号
                        measuring_project: result.data[i].measuring_project, //检测项目名称（三种语言，用||隔开）
                        measuring_requirement: result.data[i].measuring_requirement, //检测要求（三种语言，用||隔开）
                        measuring_type: result.data[i].measuring_type, //测量类型（是一个固定的内容：计量、计数、目视）
                        upper_tolerance: result.data[i].upper_tolerance, //上公差
                        lower_tolerance: result.data[i].lower_tolerance, //下公差
                        standard_value: result.data[i].standard_value, //标准值
                        measuring_value: jsonData[j][1],//测量值
                        measuring_person: measuring_person,//检测人名称
                        measuring_date: this.measuring_date,//检测时间
                        measuring_shift: this.measuring_shift,//检测班次
                        part_number: partNumber,//工件号
                        is_ppk: 'yes',//是否计算ppk
                        no_calculate_reason: '',//不计算ppk原因
                        measuring_project_id: result.data[i].id,//关联检测项目id
                        precision_hand:'精测/Precision measurement/Точное измерение'//精测
                      }
                      filterResult.push(resultForm)
                      console.log(filterResult)
                    }
                  }
                }
                //将组合好的数据赋值给大表
                this.tableTest=filterResult;
                //给判定的圆圈赋值
                for (let i = 0; i < this.tableTest.length; i++) {
                  this.tableTest[i].isOk=this.testValEdit(this.tableTest[i])
                }
              }
            }
        )
      }
      reader.readAsArrayBuffer(fileToRead);
      if (this.languageS==='chinese'){
        this.$message.success('文件上传成功')
      }
      else if (this.languageS==='english'){
        this.$message.success('File upload successful')
      }
      else if (this.languageS==='russian'){
        this.$message.success('Загрузка файла успешна')
      }
      // 清空已选文件列表
      this.$refs.excelUpload.clearFiles();
    },

    //上传数据成功 手检
    //eslint-disable-next-line no-unused-vars
    handleUploadDataSuccessHand(file, fileList) {
      // 获取文件名
      const fileName = file.name; // 这是获取文件名的方式
      // 处理上传成功逻辑
      const fileToRead = file.raw || null; // 使用可选链操作符来安全地访问 raw 属性
      if (!fileToRead) return;
      const reader = new FileReader();
      reader.onload = (e) => {
        //组合成Json格式
        const data = new Uint8Array(e.target.result);
        const workbook = XLSX.read(data, {type: 'array'});
        const firstSheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[firstSheetName];
        const jsonData = XLSX.utils.sheet_to_json(worksheet, {header: 1});
        //找到图号
        let drawing_number
        if (fileName.split('-')[1]==='Cylinder Block'){
          drawing_number='1002100XEB75'
        }
        else if(fileName.split('-')[1]==='Cylinder Head'){
          drawing_number='1003100AEB75'
        }
        // 确定工序号
        const fileNameParts = fileName.split('-');
        let op = '';

        if (fileNameParts.length === 5) {
          if (fileName.includes('-1') || fileName.includes('-2')) {
            op = fileNameParts[2] + '-' + fileNameParts[3];
          }
        } else if (fileNameParts.length === 4) {
          op = fileNameParts[2];
        }
        this.$request.post('/precisionMeasProjectInquiryThreeField',{
          firstFieldName:'workshop',
          firstFieldVal:'机加车间/Machining workshop/Цех механической обработки',
          secondFieldName:'drawing_number',
          secondFieldVal:drawing_number,
          thirdName:'op',
          thirdVal:op
        }).then(
            result=>{
              if (result.code === 401) {
                this.$router.push('UserLogin')
                alert("您未登录，请登录")
              }
              else {
                let filterResult = []
                for (let i = 0; i < result.data.length; i++) {
                  let temp = result.data[i].measuring_project.split('|*|')[0]
                  //filterResult是筛出来中文检测项目
                  for (let j = 0; j < jsonData.length; j++) {
                    let after
                    after = jsonData[j][0]
                    if (after === temp) {
                      let resultForm = {
                        id: null, // 主键
                        create_time: null, // 创建时间
                        update_time: null, // 修改时间
                        creator: this.useName, // 编辑人
                        process_status: '',//流程状态
                        sys_update_user: '',//更新人
                        sys_audit_user: '',//审核人
                        sys_audit_time: '',//审核时间
                        sys_deleted: 0, //删除标记位 (0表示未删除)
                        workshop: '机加车间/Machining workshop/Цех механической обработки', //车间名称三种语言（‘/’分割）
                        drawing_number: result.data[i].drawing_number, //产品图号
                        op: result.data[i].op, //工序号
                        measuring_project: result.data[i].measuring_project, //检测项目名称（三种语言，用||隔开）
                        measuring_requirement: result.data[i].measuring_requirement, //检测要求（三种语言，用||隔开）
                        measuring_type: result.data[i].measuring_type, //测量类型（是一个固定的内容：计量、计数、目视）
                        upper_tolerance: result.data[i].upper_tolerance, //上公差
                        lower_tolerance: result.data[i].lower_tolerance, //下公差
                        standard_value: result.data[i].standard_value, //标准值
                        measuring_value: jsonData[j][3],//测量值
                        measuring_person: jsonData[2][1],//检测人名称
                        measuring_date: this.measuring_date,//检测时间
                        measuring_shift: this.measuring_shift,//检测班次
                        part_number: jsonData[1][1],//工件号
                        is_ppk: 'yes',//是否计算ppk
                        no_calculate_reason: '',//不计算ppk原因
                        measuring_project_id: result.data[i].id,//关联检测项目id
                        precision_hand:'手检/Hand inspection/Ручное осмотрение'//精测
                      }
                      filterResult.push(resultForm)
                      // console.log(filterResult)
                    }
                  }
                }
                //将组合好的数据赋值给大表
                this.tableTest=filterResult;
                //给判定的圆圈赋值
                for (let i = 0; i < this.tableTest.length; i++) {
                  this.tableTest[i].isOk=this.testValEdit(this.tableTest[i])
                }
              }
            }
        )
      }
      reader.readAsArrayBuffer(fileToRead);
      if (this.languageS==='chinese'){
        this.$message.success('文件上传成功')
      }
      else if (this.languageS==='english'){
        this.$message.success('File upload successful')
      }
      else if (this.languageS==='russian'){
        this.$message.success('Загрузка файла успешна')
      }
      // 清空已选文件列表
      this.$refs.excelUpload.clearFiles();
    },

    //辅助函数：转化excel导入时间
    excelDateToJSDate(excelDate, excelTime = 0) {
      // Excel的日期是从1900年1月1日开始（注意：Excel错误地认为1900是闰年）
      const excelEpoch = new Date(1899, 11, 31);
      // 计算完整的天数（Excel日期是1-based）
      const days = Math.floor(excelDate) - 1; // 减去1因为Excel从1开始计数
      // 计算时间部分（小数部分）
      const time = excelTime % 1;
      const hours = time * 24;
      const minutes = (hours % 1) * 60;
      const seconds = (minutes % 1) * 60;

      // 创建日期对象
      const date = new Date(excelEpoch);
      date.setDate(excelEpoch.getDate() + days);
      date.setHours(Math.floor(hours), Math.floor(minutes), Math.floor(seconds));

      return date;
    },

    //————————————————————————————————————————趋势管理—————————————————————————————————————————
    //画图
    changeDataQuantity(quantity, measuring_project_id){
      this.$request.post("/queryMeasuringProjectByOneFieldMacTestCon",{
        quantity: quantity,
        measuring_project_id: measuring_project_id,
      }).then(result=>{
        if (result.code === 401) {
          this.$router.push('UserLogin');
          this.$message.error("您未登录，请登录");
        }
        else {
          //用户可能想看到参与计算的原始数据，那么直接把筛选出来的数据给了原始数据

          //给直方图准备的测量值
          let testValues=[]
          //折线图
          let optionLine={
                title:{
                  //设置标题的样式
                  textStyle:{
                    color:'red',
                  },
                  //设置标题的居中方式（水平）
                  x:'center',
                  text:'暂未选择',
                },
                xAxis:{
                  data:[]
                },
                yAxis:{
                  type: 'value',
                  min:0, // 设置y轴的最小值
                  max:100,//设置y轴的最大值
                },
                series:[
                   {
                  //设置系列，设置当前映射出的图形
                  name:'valueUse',
                  type:'line',
                  stack:'num',
                  data:[]
                },
                  {
                    //设置系列，设置当前映射出的图形
                    name:'standard',
                    type:'line',
                    stack:'standard',
                    data:[]
                  },
                  {
                    //设置系列，设置当前映射出的图形
                    name:'ceiling',
                    type:'line',
                    stack:'ceiling',
                    data:[]
                  },
                  {
                    //设置系列，设置当前映射出的图形
                    name:'lower',
                    type:'line',
                    stack:'lower',
                    data:[]
                  },],
                grid: {
                  top:'15%',
                  left: '2%', // 图表内容距离容器左侧的距离
                  right: '2%', // 图表内容距离容器右侧的距离
                  bottom: '10%', // 图表内容距离容器底部的距离，可以适当增加这个值来留出更多空间给标题
                  containLabel: true, // 网格是否包含坐标轴的标签在内
                },
                tooltip:{
                  //触发类型
                  trigger:'axis',
                  //设置坐标轴的指示器
                  axisPointer:{
                    type: 'cross'
                  },
                },
            // 添加 toolbox 配置
            toolbox: {
              feature: {
                saveAsImage: {
                  title: '下载图表', // 按钮提示文字
                  type: 'png', // 默认保存为 png 格式
                  pixelRatio: 2 // 图片分辨率比例，默认为1
                }
              },
              right: 5, // 工具箱位置，距离右侧20px
              top: 0 // 工具箱位置，距离顶部20px
            }
              }
          if (result.data.length>1){
            //为使图表的x轴日期从小到大，采取倒循环
            for (let i = result.data.length-1; i >= 0; i--) {
              testValues.push(Number(result.data[i].measuring_value))
              optionLine.xAxis.data.push(result.data[i].measuring_date)
              optionLine.series[0].data.push(result.data[i].measuring_value)
              optionLine.series[1].data.push(result.data[i].standard_value)
              optionLine.series[2].data.push(Number(result.data[i].standard_value)+Number(result.data[i].upper_tolerance))
              optionLine.series[3].data.push(Number(result.data[i].standard_value)+Number(result.data[i].lower_tolerance))
            }
            //设置图表标题
            if (this.languageS==='chinese'){
              optionLine.title.text=result.data[0].measuring_project.split('|*|')[0]
            }
            if (this.languageS==='english'){
              optionLine.title.text=result.data[0].measuring_project.split('|*|')[1]
            }
            if (this.languageS==='russian'){
              optionLine.title.text=result.data[0].measuring_project.split('|*|')[2]
            }
            //设置图表y轴最大值
            optionLine.yAxis.max=Number(result.data[0].standard_value)+2*Number(result.data[0].upper_tolerance)
            //设置图表y轴最小值
            optionLine.yAxis.min=Number(result.data[0].standard_value)+2*Number(result.data[0].lower_tolerance)
          }
          //如果折线图已有数据，先清空
          if (this.lineChartData) {
            this.lineChartData.dispose()
          }
          this.lineChartData=echarts.init(this.$refs.lineChart)
          this.lineChartData.setOption(optionLine)

          //直方图
          let optionBar={
            title:{
              //设置标题的样式
              textStyle:{
                color:'red',
              },
              //设置标题的居中方式（水平）
              x:'center',
              text:'暂未选择',
              top: '-3px', // 标题距离容器顶部的距离（百分比或像素值，如 '20px'）
            },
            xAxis:[
                {
              data:[]
                },
              {
                type: 'value',
                name: '辅助X轴',
                position: 'top',
                min: 0,
                max: 1,
                axisLabel: { show: false }, // 隐藏数值标签
                axisLine: { show: false },  // 隐藏轴线
                axisTick: { show: false }   // 隐藏刻度线
              }
            ],
            yAxis: [
              { // 主 Y 轴（左侧，默认）
                type: 'value',
                min: 0,
                max: 100,
                name: '频数', // 可选：添加主 Y 轴标签
              },
              { // 副 Y 轴（右侧，用于分布曲线）
                type: 'value',
                min: 0, // 根据数据动态调整
                max: 1, // 假设分布曲线是概率密度，范围在 0~1
                name: '概率密度', // 可选：添加副 Y 轴标签
                splitLine: { show: false }, // 可选：隐藏副 Y 轴的网格线
              }
            ],
            series:[
              {
                //设置系列，设置当前映射出的图形
                name:'valueUse',
                type:'bar',
                stack:'num',
                data:[],
                xAxisIndex: 0, // 关联主X轴
              },
              {
                name: '上下限',
                type: 'line',
                smooth: true, // 启用平滑曲线
                symbol: 'none', // 隐藏数据点标记
                lineStyle: {
                  width: 3,
                  color: '#FF6347' // 设置折线颜色
                },
                data: [], // 折线图数据
                xAxisIndex: 0, // 关联主X轴
                yAxisIndex: 1, // 关键：指定使用第二个 Y 轴（副 Y 轴）
              },
              {
                name: '',
                type: 'line',
                smooth: true, // 启用平滑曲线
                symbol: 'none', // 隐藏数据点标记
                lineStyle: {
                  width: 3,
                  color: '#FF6347' // 设置折线颜色
                },
                //添加一条竖直的线
                markLine: {
                  silent: true, // 不触发事件
                  symbol: 'none',//隐藏箭头和圆点
                  lineStyle: {
                    color: 'red', // 线条颜色
                    width: 2,     // 线条宽度
                    type: 'solid' // 实线
                  },
                  label: {
                    show: true, // 显示标签
                    formatter: function(params) {
                      // 根据不同的线返回不同的标签（UCL 或 LCL）
                      return params.data.label || ''; // 默认显示空，或通过 data 中自定义
                    },
                    position: 'end', // 标签位置（可选：'start', 'middle', 'end'）
                    color: 'red', // 标签颜色（与线条一致）
                    fontSize: 12 // 字体大小
                  },
                  data: [
                    {
                      xAxis: this.formatDecimal(Number(result.data[0].standard_value)+Number(result.data[0].upper_tolerance),3),
                      label: 'UCL', // 自定义标签
                      lineStyle: { color: 'red' } // 可单独设置颜色（可选）
                    },
                    // 第二条线：x = 0.117，标签为 "LCL"
                    {
                      xAxis: this.formatDecimal(Number(result.data[0].standard_value)+Number(result.data[0].lower_tolerance),3),
                      label: 'LCL', // 自定义标签
                      lineStyle: { color: 'red' } // 可单独设置颜色（可选）
                    }
                  ]
                },
                data: [], // 折线图数据
                xAxisIndex: 1, // 关联主X轴
                yAxisIndex: 0, // 关键：指定使用第二个 Y 轴（副 Y 轴）
              },
              ],
            grid: {
              top:'20%',
              left: '2%', // 图表内容距离容器左侧的距离
              right: '2%', // 图表内容距离容器右侧的距离
              bottom: '10%', // 图表内容距离容器底部的距离，可以适当增加这个值来留出更多空间给标题
              containLabel: true, // 网格是否包含坐标轴的标签在内
            },
            tooltip:{
              //触发类型
              trigger:'axis',
              //设置坐标轴的指示器
              axisPointer:{
                type: 'cross'
              },
            },
            // 添加 toolbox 配置
            toolbox: {
              feature: {
                saveAsImage: {
                  title: '下载图表', // 按钮提示文字
                  type: 'png', // 默认保存为 png 格式
                  pixelRatio: 2 // 图片分辨率比例，默认为1
                }
              },
              right: 5, // 工具箱位置，距离右侧20px
              top: 0 // 工具箱位置，距离顶部20px
            }
          }
          let barValue= this.calculateHistogramData(testValues, Number(result.data[0].standard_value), Number(result.data[0].standard_value)+Number(result.data[0].upper_tolerance), Number(result.data[0].standard_value)+Number(result.data[0].lower_tolerance), 10)
          //设置图表标题
          if (this.languageS==='chinese'){
            optionBar.title.text="直方图"
          }
          else if (this.languageS==='english'){
            optionBar.title.text="Histogram"
          }
          else if (this.languageS==='russian'){
            optionBar.title.text="Гистограмма"
          }
          //设置图表x轴
          optionBar.xAxis[0].data=barValue.binEdges
          optionBar.xAxis[1].max=Number(barValue.binEdges[barValue.binEdges.length-1])
          optionBar.xAxis[1].min=Number(barValue.binEdges[0])
          //设置图表数据(柱状图）
          optionBar.series[0].data=barValue.frequencies
          //设置图标数据（正泰分布图）
          optionBar.series[1].data=barValue.normalDistribution
          //设置图表y值
          optionBar.yAxis[0].max=Math.max(...barValue.frequencies)+1
          optionBar.yAxis[0].min=0
          //赋值,画图
          if (this.barChartData) {
            this.barChartData.dispose()
          }
          this.barChartData=echarts.init(this.$refs.barChart)
          this.barChartData.setOption(optionBar)

          //画移动极差图
          let movingRangeValue = this.calculateMovingRangeData(testValues)
          let optionMovingRange={
            title:{
              //设置标题的样式
              textStyle:{
                color:'red',
              },
              //设置标题的居中方式（水平）
              x:'center',
              text:"",
            },
            xAxis:{
              data:[]
            },
            yAxis:{
              type: 'value',
              min:0, // 设置y轴的最小值
              max:100,//设置y轴的最大值
            },
            series:[
              {
                //设置系列，设置当前映射出的图形
                name:'valueUse',
                type:'line',
                stack:'num',
                data:[]
              },
              {
                //设置系列，设置当前映射出的图形
                name:'standard',
                type:'line',
                stack:'standard',
                data:[]
              },
              {
                //设置系列，设置当前映射出的图形
                name:'ceiling',
                type:'line',
                stack:'ceiling',
                data:[]
              },
              {
                //设置系列，设置当前映射出的图形
                name:'lower',
                type:'line',
                stack:'lower',
                data:[]
              },],
            grid: {
              top:'20%',
              left: '2%', // 图表内容距离容器左侧的距离
              right: '2%', // 图表内容距离容器右侧的距离
              bottom: '10%', // 图表内容距离容器底部的距离，可以适当增加这个值来留出更多空间给标题
              containLabel: true, // 网格是否包含坐标轴的标签在内
            },
            tooltip:{
              //触发类型
              trigger:'axis',
              //设置坐标轴的指示器
              axisPointer:{
                type: 'cross'
              },
            },
            // 添加 toolbox 配置
            toolbox: {
              feature: {
                saveAsImage: {
                  title: '下载图表', // 按钮提示文字
                  type: 'png', // 默认保存为 png 格式
                  pixelRatio: 2 // 图片分辨率比例，默认为1
                }
              },
              right: 5, // 工具箱位置，距离右侧20px
              top: 0 // 工具箱位置，距离顶部20px
            }
          }
          //设置图表标题
          if (this.languageS==='chinese'){
            optionMovingRange.title.text="移动极差图"
          }
          else if (this.languageS==='english'){
            optionMovingRange.title.text="Moving Range Chart"
          }
          else if (this.languageS==='russian'){
            optionMovingRange.title.text="Диаграмма скользящих размахов"
          }
          for (let i = 0; i < movingRangeValue.movingRanges.length; i++) {
            optionMovingRange.xAxis.data=i+1
            //赋值测量值
            optionMovingRange.series[0].data.push(this.formatDecimal(movingRangeValue.movingRanges[i],3))
            //赋值标准值
            optionMovingRange.series[1].data.push(movingRangeValue.mrBar)
            //赋值上公差
            optionMovingRange.series[2].data.push(movingRangeValue.uclMR)
            //赋值下公差
            optionMovingRange.series[3].data.push(movingRangeValue.lclMR)
          }
          optionMovingRange.yAxis.max=this.formatDecimal(Number(movingRangeValue.uclMR)*1.1,3)
          optionMovingRange.yAxis.min=0
          //如果移动极差图已有数据，先清空
          if (this.movingRangeChartData) {
            this.movingRangeChartData.dispose()
          }
          this.movingRangeChartData=echarts.init(this.$refs.movingRangeChart)
          this.movingRangeChartData.setOption(optionMovingRange)

          //计算ppk、cpk
          let ppkData=result.data
          this.ppkResult = this.calculatePpkCpk(ppkData)


          //
          this.trendResult = this.findContinuousTrendData(result.data)
        }
      })
    },

    //点击某一个项目画图的函数
    handleClickChart(row){
      this.measuringProjectRow=row
      if (this.clickQuantity!=='' && this.clickQuantity!==null && this.clickQuantity!==undefined){
        this.changeDataQuantity(this.clickQuantity, row.id)
      }
    },

    //点击多少组数据的函数
    clickQuantityButton(quantity){
      this.clickQuantity=quantity
      if (this.clickQuantity===25){
        //按钮颜色变更
        this.chartBackground25='#0269fa'
        this.chartColor25='white'
        this.chartBackground50=''
        this.chartColor50=''
        this.chartBackground125=''
        this.chartColor125=''
        this.chartBackground300=''
        this.chartColor300=''
        this.chartBackground500=''
        this.chartColor500=''
      }
      else if (this.clickQuantity==50){
        //按钮颜色变更
        this.chartBackground25=''
        this.chartColor25=''
        this.chartBackground50='#0269fa'
        this.chartColor50='white'
        this.chartBackground125=''
        this.chartColor125=''
        this.chartBackground300=''
        this.chartColor300=''
        this.chartBackground500=''
        this.chartColor500=''
      }
      else if (this.clickQuantity==125){
        //按钮颜色变更
        this.chartBackground25=''
        this.chartColor25=''
        this.chartBackground50=''
        this.chartColor50=''
        this.chartBackground125='#0269fa'
        this.chartColor125='white'
        this.chartBackground300=''
        this.chartColor300=''
        this.chartBackground500=''
        this.chartColor500=''
      }
      else if (this.clickQuantity==300){
        //按钮颜色变更
        this.chartBackground25=''
        this.chartColor25=''
        this.chartBackground50=''
        this.chartColor50=''
        this.chartBackground125=''
        this.chartColor125=''
        this.chartBackground300='#0269fa'
        this.chartColor300='white'
        this.chartBackground500=''
        this.chartColor500=''
      }
      else if (this.clickQuantity==500){
        //按钮颜色变更
        this.chartBackground25=''
        this.chartColor25=''
        this.chartBackground50=''
        this.chartColor50=''
        this.chartBackground125=''
        this.chartColor125=''
        this.chartBackground300=''
        this.chartColor300=''
        this.chartBackground500='#0269fa'
        this.chartColor500='white'
      }
      if (this.measuringProjectRow!=='' && this.measuringProjectRow!==null && this.measuringProjectRow!==undefined){
        this.changeDataQuantity(quantity,this.measuringProjectRow.id)
      }
    },

    //用户点击趋势管理中检测项目中的行，改变背景颜色
    measuringProjectRowClassName(row){
      // 如果当前行是currentRow，则返回特定的样式
      if (this.measuringProjectRow && this.measuringProjectRow === row.row) {
        return {
          backgroundColor: '#0269fa', // 蓝色背景
          color: 'grey', // 白色文字
          cursor: 'pointer' // 鼠标悬停时变成小手
        };
      }
      return {}; // 否则不应用任何样式
    },

    //辅助函数：画直方图用的
    calculateHistogramData(testValues, standardValue, upperTolerance, lowerTolerance, numBins = 10) {
      if (!testValues || testValues.length === 0) {
        throw new Error('测试值数组不能为空');
      }

      // 计算数据的最大值和最小值
      let max = Math.max(...testValues);
      if (max<upperTolerance){
        max=upperTolerance
      }
      let min = Math.min(...testValues);
      if (min>lowerTolerance){
        min=lowerTolerance
      }
      // 计算极差
      const range = max - min;
      // 计算组距
      const binWidth = range / numBins;
      // 初始化频数数组
      const frequencies = new Array(numBins).fill(0);
      // 计算每个柱子的边界
      const binEdges = [];
      for (let i = 0; i <= numBins; i++) {
        binEdges.push(this.formatDecimal(min + i * binWidth, 3));
      }

      // 统计频数
      testValues.forEach(value => {
        // 找到value应该属于哪个柱子
        const index = Math.floor((value - min) / binWidth);
        // 处理最大值的情况，确保它被包含在最后一个柱子中
        const finalIndex = index >= numBins ? numBins - 1 : index;
        frequencies[finalIndex]++;
      });

      // 计算正态分布曲线数据（新增部分）
      const normalDistributionData = [];
      const binCenters = []; // 存储每个柱子的中心点
      for (let i = 0; i < numBins; i++) {
        const center = (Number(binEdges[i]) + Number(binEdges[i + 1])) / 2; // 计算柱子中心点
        binCenters.push(Number(center));
      }

      // 计算均值和标准差
      const mean = testValues.reduce((sum, val) => sum + val, 0) / testValues.length;
      const variance = testValues.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / testValues.length;
      const stdDev = Math.sqrt(variance);

      // 正态分布函数
      const normalDist = (x) => {
        return (1 / (stdDev * Math.sqrt(2 * Math.PI))) *
            Math.exp(-Math.pow(x - mean, 2) / (2 * Math.pow(stdDev, 2)));
      };

      // 计算归一化因子，使曲线最大值与直方图最大频数匹配
      const maxDensity = Math.max(...binCenters.map(x => normalDist(x)));
      const maxFrequency = Math.max(...frequencies);
      const scaleFactor = maxFrequency / maxDensity;

      // 生成正态分布曲线数据（归一化后与直方图比例匹配）
      for (let i = 0; i < numBins; i++) {
        const center = binCenters[i];
        // 乘以binWidth和scaleFactor进行归一化
        const density = normalDist(center) * scaleFactor * binWidth * testValues.length;
        normalDistributionData.push(this.formatDecimal(density, 3)); // 格式化数据
      }

      // 准备返回的数据（包含正态分布曲线数据）
      const histogramData = {
        binEdges: binEdges,
        binCenters: binCenters, // 新增：柱子中心点（可用于折线图x轴）
        frequencies: frequencies,
        normalDistribution: normalDistributionData, // 新增：正态分布曲线数据
        standardValue: standardValue,
        upperTolerance: upperTolerance,
        lowerTolerance: lowerTolerance,
        testValues: testValues,
        mean: this.formatDecimal(mean, 3), // 新增：均值（可选）
        stdDev: this.formatDecimal(stdDev, 3) // 新增：标准差（可选）
      };

      return histogramData;
    },
    //辅助函数：画移动极差图用的
    calculateMovingRangeData(data) {
      if (!Array.isArray(data) || data.length < 2) {
        throw new Error('输入必须是一个包含至少2个数字的数组');
      }
      // 1. 计算移动极差（MR）
      const movingRanges = [];
      for (let i = 1; i < data.length; i++) {
        movingRanges.push(Math.abs(data[i] - data[i - 1]));
      }
      // 2. 计算平均移动极差（MR-bar）
      const mrBar = movingRanges.reduce((sum, mr) => sum + mr, 0) / movingRanges.length;
      // 3. 计算控制限
      // D4和D3是移动极差图的常数，对于子组大小n=2时：
      const D4 = 3.267;
      const D3 = 0; // 对于n=2，D3=0

      const uclMR = D4 * mrBar; // 移动极差上限
      const lclMR = D3 * mrBar; // 移动极差下限（通常为0）

      // 4. 计算个体图的控制限（用于X图）
      // A2是个体图的常数，对于n=2时：
      const A2 = 1.880;

      const xBar = data.reduce((sum, x) => sum + x, 0) / data.length;
      const uclX = xBar + A2 * mrBar;
      const lclX = xBar - A2 * mrBar;

      return {
        // 原始数据
        originalData: [...data],

        // 移动极差数据
        movingRanges: movingRanges,
        mrBar: mrBar,
        uclMR: uclMR,
        lclMR: lclMR,

        // 个体图数据
        xBar: xBar,
        uclX: uclX,
        lclX: lclX,

        // 其他统计量
        sampleSize: 2, // 移动极差的子组大小固定为2
        dataPoints: data.length,

        // 辅助方法
        isWithinControlLimits: function(value, type = 'X') {
          if (type === 'X') {
            return value >= this.lclX && value <= this.uclX;
          } else if (type === 'MR') {
            return value >= this.lclMR && value <= this.uclMR;
          }
          return false;
        }
      };
    },

    //计算ppk、cpk
    /**
     * 计算 Ppk 和 Cpk
     * @param {Array} tableTestVal 数据数组
     * @returns {Object} { ppk, cpk } 或错误信息
     */
    calculatePpkCpk(tableTestVal) {
      console.log(tableTestVal)
      // 1. 提取有效的 measuring_value 并转换为数值数组
      const measuringValues = tableTestVal
          .map(item => parseFloat(item.measuring_value))
          .filter(value => !isNaN(value));

      if (measuringValues.length < 2) {
        return { error: "有效测量值不足（至少需要2个数据点）" };
      }

      // 2. 获取规格上下限
      const sampleItem = tableTestVal.find(item =>
          item.upper_tolerance && item.lower_tolerance &&
          item.standard_value !== undefined
      );
      console.log(sampleItem)

      if (!sampleItem) {
        return { error: "缺少规格上限(USL)或下限(LSL)" };
      }

      const USL = parseFloat(Number(sampleItem.upper_tolerance)+Number(sampleItem.standard_value));

      const LSL = parseFloat(Number(sampleItem.lower_tolerance)+Number(sampleItem.standard_value));

      // 3. 验证规格有效性
      if (USL <= LSL) {
        return { error: "规格上限必须大于下限" };
      }

      // 4. 计算统计量
      const n = measuringValues.length;
      const mean = measuringValues.reduce((sum, val) => sum + val, 0) / n;

      // 计算样本标准差（用于Cpk）
      const sampleVariance = measuringValues
          .map(val => Math.pow(val - mean, 2))
          .reduce((sum, val) => sum + val, 0) / (n - 1);

      const sampleSigma = Math.sqrt(sampleVariance);

      // 计算总体标准差（用于Ppk）
      const populationVariance = measuringValues
          .map(val => Math.pow(val - mean, 2))
          .reduce((sum, val) => sum + val, 0) / n;

      const populationSigma = Math.sqrt(populationVariance);

      // 5. 计算 Cpk 和 Ppk
      const calculateIndex = (targetMean, usl, lsl, sigma) => {
        const cpu = (usl - targetMean) / (3 * sigma);
        const cpl = (targetMean - lsl) / (3 * sigma);
        return Math.min(cpu, cpl);
      };

      // 6. 边界条件检查
      if (sampleSigma === 0 || populationSigma === 0) {
        return { error: "标准差为零，无法计算能力指数" };
      }

      const cpk = calculateIndex(mean, USL, LSL, sampleSigma);
      const ppk = calculateIndex(mean, USL, LSL, populationSigma);

      return {
        ppk: parseFloat(ppk.toFixed(4)),
        cpk: parseFloat(cpk.toFixed(4)),
        mean: parseFloat(mean.toFixed(4)),
        sampleSigma: parseFloat(sampleSigma.toFixed(4)),
        populationSigma: parseFloat(populationSigma.toFixed(4)),
        usl: USL,
        lsl: LSL,
        count: n
      };
    },

    /**
     * 检测连续6点及以上上升或下降的数据行
     * @param {Array} tableData - 数据数组
     * @returns {Array} 返回所有符合条件的连续数据组（每组包含趋势类型和对应的整行数据）
     */
    findContinuousTrendData(tableData) {
      const result = {
        hasContinuousIncreasing: false,
        hasContinuousDecreasing: false,
        continuousIncreasingData: [],
        continuousDecreasingData: []
      };

      const validData = tableData.filter(item => item.measuring_value !== null && item.measuring_value !== undefined);

      if (validData.length < 6) return result;

      let currentTrend = null;
      let startIndex = 0;

      for (let i = 1; i < validData.length; i++) {
        const prev = validData[i - 1].measuring_value;
        const curr = validData[i].measuring_value;

        if (curr > prev) {
          if (currentTrend === 'decreasing') {
            if (i - 1 - startIndex >= 5) {
              result.hasContinuousDecreasing = true;
              result.continuousDecreasingData.push(validData.slice(startIndex, i));
            }
            startIndex = i - 1;
          }
          currentTrend = 'increasing';
        } else if (curr < prev) {
          if (currentTrend === 'increasing') {
            if (i - 1 - startIndex >= 5) {
              result.hasContinuousIncreasing = true;
              result.continuousIncreasingData.push(validData.slice(startIndex, i));
            }
            startIndex = i - 1;
          }
          currentTrend = 'decreasing';
        } else {
          if (currentTrend) {
            if (i - 1 - startIndex >= 5) {
              if (currentTrend === 'increasing') {
                result.hasContinuousIncreasing = true;
                result.continuousIncreasingData.push(validData.slice(startIndex, i));
              } else {
                result.hasContinuousDecreasing = true;
                result.continuousDecreasingData.push(validData.slice(startIndex, i));
              }
            }
          }
          currentTrend = null;
          startIndex = i;
        }

        if (i === validData.length - 1 && currentTrend) {
          if (i - startIndex >= 5) {
            if (currentTrend === 'increasing') {
              result.hasContinuousIncreasing = true;
              result.continuousIncreasingData.push(validData.slice(startIndex, i + 1));
            } else {
              result.hasContinuousDecreasing = true;
              result.continuousDecreasingData.push(validData.slice(startIndex, i + 1));
            }
          }
        }
      }

      return result;
    },

    //显示连续六点上升/下降数据的弹窗
    showTrendDialog(type) {
      if (this.languageS==='chinese'){
        this.titleUse="连续6点(及以上)上升/下降数据"
      }
      else if (this.languageS==='english'){
        this.titleUse="Continuous increase/decrease data for 6 (or more points)"
      }
      else if (this.languageS==='russian'){
        this.titleUse="Непрерывное увеличение/уменьшение данных на 6 (или более пунктов)"
      }
      this.continuousData=[]
      if (type==="increasing"){
        for (let i = 0; i < this.trendResult.continuousIncreasingData.length; i++) {
          this.continuousData=this.continuousData.concat(this.trendResult.continuousIncreasingData[i])
        }
      }
      else if(type==="decreasing"){
        for (let i = 0; i < this.trendResult.continuousDecreasingData.length; i++) {
          this.continuousData=this.continuousData.concat(this.trendResult.continuousDecreasingData[i])
        }
      }
      this.continuousDataDialog = true;
    },

    //————————————————————————————————————————原始数据—————————————————————————————————————————
    // 处理筛选条件
    handleFilter() {
      // 先获取基础条件
      const baseConditions = this.getBaseConditions();

      // 构建筛选参数（使用正确的字段名）
      const filterParams = {};

      // 使用正确的字段名 fieldName5 到 fieldName9
      if (this.measuring_project) {
        filterParams.fieldName5 = 'measuring_project';
        filterParams.fieldValue5 = this.measuring_project;
      }
      if (this.part_number) {
        filterParams.fieldName6 = 'part_number';
        filterParams.fieldValue6 = this.part_number;
      }
      if (this.measuring_date) {
        filterParams.fieldName7 = 'measuring_date';
        filterParams.fieldValue7 = this.measuring_date;
      }
      if (this.measuring_person) {
        filterParams.fieldName8 = 'measuring_person';
        filterParams.fieldValue8 = this.measuring_person;
      }
      if (this.measuring_shift) {
        filterParams.fieldName9 = 'measuring_shift';
        filterParams.fieldValue9 = this.measuring_shift;
      }

      // 合并基础条件和筛选条件
      const allConditions = {
        ...baseConditions,
        ...filterParams
      };

      // 重置到第一页
      this.measuringResultPagination.currentPage = 1;

      // 调用新的动态查询方法
      this.queryPrecisionMeasurementValue(allConditions);
    },
    // 获取基础查询条件
    getBaseConditions() {
      if (!this.treeUseNode || this.treeUseNode.level !== 3) {
        return {};
      }

      let fourData = {
        firstName: 'workshop',
        firstValue: '机加车间/Machining workshop/Цех механической обработки',
        secondName: 'drawing_number',
        secondValue: this.treeUseNode.parent.data.label,
        thirdName: 'op',
        thirdValue: this.treeUseOp,
        forthName: 'precision_hand',
        forthValue: ''
      }

      // 正确设置手检/精测条件
      if (this.treeUseNode.parent.parent.data.label === '机加车间' ||
          this.treeUseNode.parent.parent.data.label === 'Machining workshop' ||
          this.treeUseNode.parent.parent.data.label === 'Цех механической обработки') {
        fourData.forthValue = '精测/Precision measurement/Точное измерение';
      } else if (this.treeUseNode.parent.parent.data.label === '机加车间-手检' ||
          this.treeUseNode.parent.parent.data.label === 'Machining workshop-Hand inspection' ||
          this.treeUseNode.parent.parent.data.label === 'Цех механической обработки-Ручное осмотрение') {
        fourData.forthValue = '手检/Hand inspection/Ручное осмотрение';
      }

      return {
        fieldName1: fourData.firstName,
        fieldValue1: fourData.firstValue,
        fieldName2: fourData.secondName,
        fieldValue2: fourData.secondValue,
        fieldName3: fourData.thirdName,
        fieldValue3: fourData.thirdValue,
        fieldName4: fourData.forthName,
        fieldValue4: fourData.forthValue
      };
    },
    // 去后端查询筛选后的数据
    async queryPrecisionMeasurementValue(allConditions) {
      const { currentPage, pageSize } = this.measuringResultPagination;

      try {
        // 直接调用查询接口，后端会同时返回数据和总数
        const result = await this.$request.post('/queryPrecisionMeasurementValueByDynamicConditionsMacTestCon', {
          ...allConditions,
          page: (currentPage - 1) * pageSize,  // 计算偏移量
          size: pageSize
        });

        if (result.code === 401) {
          this.$router.push('UserLogin');
          alert("您未登录，请登录");
          return;
        }

        // 更新数据
        this.tableTestVal = result.data.data || [];
        this.filteredTableData = [...this.tableTestVal];

        // 更新总数
        this.measuringResultPagination.total = result.data.total || 0;

        console.log('查询结果:', {
          currentPage: currentPage,
          pageSize: pageSize,
          total: this.measuringResultPagination.total,
          dataCount: this.tableTestVal.length
        });

        this.componentKey++; // 强制刷新表格
      } catch (error) {
        console.error('查询数据失败:', error);
        if (this.languageS === 'chinese') {
          this.$message.error('查询数据失败');
        } else if (this.languageS === 'english') {
          this.$message.error('Query data failed');
        } else if (this.languageS === 'russian') {
          this.$message.error('Не удалось запросить данные');
        }
      }
    },
    // 重置筛选条件
    async resetFilter() {
      this.measuring_project = '';
      this.part_number = '';
      this.measuring_date = '';
      this.measuring_person = '';
      this.measuring_shift = '';

      // 重新加载分页数据（使用基础条件）
      this.measuringResultPagination.currentPage = 1;

      const baseConditions = this.getBaseConditions();
      await this.queryPrecisionMeasurementValue(baseConditions);
    },

    //编辑某行原始数据
    measuringValueEditShow(doe,scope){
      this.tableTestValDoe=doe
      this.tableTestValScope=scope
      if(doe===1){
        if (this.languageS==='chinese'){
          this.titleUse='您正在修改一条测量结果'
        }
        else if (this.languageS==='english'){
          this.titleUse='You are editing one line of measuring value'
        }
        else if (this.languageS==='russian'){
          this.titleUse='Вы редактируете одну строку измерения значения'
        }
        //给表单赋值
        this.tableTestValForm=_.cloneDeep(scope.row)
        //控制弹窗打开
        this.measuringValueEditDialog=true
      }
    },
    //提交原始数据修改结果
    measuringValueEditOk(){
      if (this.tableTestValForm.upper_tolerance==='' || this.tableTestValForm.upper_tolerance===null || this.tableTestValForm.upper_tolerance===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入上公差')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the upper tolerance')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите верхний допуск')
        }
        return;
      }
      if (this.tableTestValForm.lower_tolerance==='' || this.tableTestValForm.lower_tolerance===null || this.tableTestValForm.lower_tolerance===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入下公差')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the lower tolerance')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите нижний допуск')
        }
        return;
      }
      if (this.tableTestValForm.standard_value==='' || this.tableTestValForm.standard_value===null || this.tableTestValForm.standard_value===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入标准值')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the standard value')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите стандартное значение')
        }
        return;
      }
      if (this.tableTestValForm.part_number==='' || this.tableTestValForm.part_number===null || this.tableTestValForm.part_number===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入工件号')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the workpiece number')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите номер детали')
        }
        return;
      }
      if (this.tableTestValForm.measuring_date==='' || this.tableTestValForm.measuring_date===null || this.tableTestValForm.measuring_date===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入检测日期')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the inspection date')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите дату проверки')
        }
        return;
      }
      if (this.tableTestValForm.measuring_person==='' || this.tableTestValForm.measuring_person===null || this.tableTestValForm.measuring_person===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入测量人')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the measurer')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите измерителя')
        }
        return;
      }
      if (this.tableTestValForm.measuring_shift==='' || this.tableTestValForm.measuring_shift===null || this.tableTestValForm.measuring_shift===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入班次')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the shift')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите смену')
        }
        return;
      }
      if (this.tableTestValForm.measuring_value==='' || this.tableTestValForm.measuring_value===null || this.tableTestValForm.measuring_value===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('请输入实测值')
        }
        else if (this.languageS==='english'){
          this.$message.error('Please enter the measured value')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Пожалуйста, введите измеренное значение')
        }
        return;
      }
      if (this.tableTestValForm.upper_tolerance<=this.tableTestValForm.lower_tolerance){
        if (this.languageS==='chinese'){
          this.$message.error('公差带范围异常，请核对')
        }
        else if (this.languageS==='english'){
          this.$message.error('Tolerance range is abnormal, please verify')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Диапазон допуска ненормальный, пожалуйста, проверьте')
        }
        return;
      }
      if (!this.isNumber(this.tableTestValForm.standard_value)){
        if (this.languageS==='chinese'){
          this.$message.error('标准值非数字，请更改')
        }
        else if (this.languageS==='english'){
          this.$message.error('Standard value is not a number, please change')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Стандартное значение не является числом, пожалуйста, измените')
        }
        return;
      }
      if (!this.isNumber(this.tableTestValForm.upper_tolerance)){
        if (this.languageS==='chinese'){
          this.$message.error('上公差非数字，请更改')
        }
        else if (this.languageS==='english'){
          this.$message.error('Upper tolerance is not a number, please change')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Верхний допуск не является числом, пожалуйста, измените')
        }
        return;
      }
      if (!this.isNumber(this.tableTestValForm.lower_tolerance)){
        if (this.languageS==='chinese'){
          this.$message.error('下公差非数字，请更改')
        }
        else if (this.languageS==='english'){
          this.$message.error('Lower tolerance is not a number, please change')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Нижний допуск не является числом, пожалуйста, измените')
        }
        return;
      }
      //当编辑某一行时
      if (this.tableTestValDoe===1){
        this.$request.post('/editMeasuringValueMacTestCon',this.tableTestValForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示编辑成功
          else{
            if (this.languageS==='chinese'){
              this.$message.success('编辑成功')
            }
            else if (this.languageS==='english'){
              this.$message.success('Edit successfully')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Редактировать успешно')
            }
            //修改大表数据
            this.tableTestVal.splice(this.tableTestValScope.$index,1,this.tableTestValForm)

            //关闭窗口
            this.measuringValueEditDialog=false
          }
        })
      }
    },
    //编辑是否计算ppk
    removeMeasuringValueOneRow(doe,scope){
      this.tableTestValDoe=doe
      this.tableTestValScope=scope
      if(doe===1){
        if (this.languageS==='chinese'){
          this.titleUse='您正在移除一条计算ppk的数据'
        }
        else if (this.languageS==='english'){
          this.titleUse='You are removing data for calculating "ppk"'
        }
        else if (this.languageS==='russian'){
          this.titleUse='Вы удаляете данные для расчета "ppk"'
        }
        //给表单赋值
        this.tableTestValForm=_.cloneDeep(scope.row)
        this.tableTestValForm.is_ppk = "no";
        //控制弹窗打开
        this.ppkDialog=true
      }
    },
    //提交原始数据修改结果
    ppkEditOk(){
      //数据校验：当用户有字段未输入内容时，提示未输入
      if(this.tableTestValForm.no_calculate_reason==='' || this.tableTestValForm.no_calculate_reason===null || this.tableTestValForm.no_calculate_reason===undefined){
        if (this.languageS==='chinese'){
          this.$message.error('您未输入"不计算ppk原因"，请输入')
        }
        else if (this.languageS==='english'){
          this.$message.error('Enter the reason for not calculating ppk')
        }
        else if (this.languageS==='russian'){
          this.$message.error('Введите причину неприсчета ppk')
        }
        return
      }
      //当编辑某一行时
      if (this.tableTestValDoe===1){
        this.$request.post('/editMeasuringValueMacTestCon',this.tableTestValForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示编辑成功
          else{
            if (this.languageS==='chinese'){
              this.$message.success('编辑成功')
            }
            else if (this.languageS==='english'){
              this.$message.success('Edit successfully')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Редактировать успешно')
            }
            //修改大表数据
            this.tableTestVal.splice(this.tableTestValScope.$index,1,this.tableTestValForm)
            //重新读取点检表数据

            //关闭窗口
            this.ppkDialog=false
          }
        })
      }
    },

    //————————————————————————————————————————删除—————————————————————————————————————————
    //通用：点击删除按钮时的弹窗
    deleteDataShow(doe,scope){
      this.deleteDataDoe=doe
      //删除原始数据某行
      if (doe==='deleteMeasuringValueOneRow'){
        this.tableTestValScope=scope
        this.tableTestValForm=_.cloneDeep(scope.row)
        if (this.languageS==="chinese"){
          this.titleUse='删除本行数据'
        }
        else if (this.languageS==="english"){
          this.titleUse='Delete this row'
        }
        else if (this.languageS==="russian"){
          this.titleUse='Удалить эту строку'
        }
        this.deleteDataDialog=true
      }
      //删除检测项目某行
      else if (doe==='deleteMeasuringProjectOneRow'){
        this.tableScope=scope
        this.tableForm=_.cloneDeep(scope.row)
        if (this.languageS==="chinese"){
          this.titleUse='删除本行数据'
        }
        else if (this.languageS==="english"){
          this.titleUse='Delete this row'
        }
        else if (this.languageS==="russian"){
          this.titleUse='Удалить эту строку'
        }
        this.deleteDataDialog=true
      }
    },
    //通用：删除某一行数据
    deleteDataOk(){
      if (this.deleteDataDoe==='deleteMeasuringValueOneRow'){
        //设置删除位的值为1
        this.tableTestValForm.sys_deleted=1
        this.$request.post('/editMeasuringValueMacTestCon',this.tableTestValForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示编辑成功
          else{
            if (this.languageS==='chinese'){
              this.$message.success('删除成功')
            }
            else if (this.languageS==='english'){
              this.$message.success('Delete successfully')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Успешно удалить')
            }
            //修改大表数据
            this.tableTestVal.splice(this.tableTestValScope.$index,1)
            //关闭窗口
            this.deleteDataDialog=false
          }
        })
      }
      else if (this.deleteDataDoe==='deleteMeasuringProjectOneRow'){
        //设置删除位的值为1
        this.tableForm.sys_deleted=1
        this.$request.post('/precisionMeasProjectEditOne',this.tableForm).then(result=>{
          //如果未接收到数据，执行用户登录界面
          if (result.code===401){
            this.$router.push('UserLogin')
            alert("您未登录，请登录")
          }
          //如果成功接收到数据，在控制台打印数据并提示编辑成功
          else{
            if (this.languageS==='chinese'){
              this.$message.success('删除成功')
            }
            else if (this.languageS==='english'){
              this.$message.success('Delete successfully')
            }
            else if (this.languageS==='russian'){
              this.$message.success('Успешно удалить')
            }
            //修改大表数据
            this.tableData.splice(this.tableScope.$index,1)
            //关闭窗口
            this.deleteDataDialog=false
          }
        })
      }
    },

    //辅助函数：查询检测结果表的某字段为某值的数据,要分页查询
    async queryPrecisionMeasurementValueFourField(firstName, firstValue, secondName, secondValue, thirdName, thirdValue, forthName, forthValue){
      const { currentPage, pageSize } = this.measuringResultPagination;
      const result = await this.$request.post('/queryPrecisionMeasurementValueFourFieldMacTestCon', {
        page: currentPage-1,
        size: pageSize,
        firstName: firstName,
        firstValue: firstValue,
        secondName: secondName,
        secondValue: secondValue,
        thirdName: thirdName,
        thirdValue:thirdValue,
        forthName:forthName,
        forthValue:forthValue
      })
      if (result.code === 401) {
        // 未登录，跳转到登录页面并提示
        this.$router.push('UserLogin');
        alert("您未登录，请登录");
        throw new Error("未登录"); // 抛出错误，表明操作失败
      }
      else {
        // 添加索引
        for (let i = 0; i < result.data.length; i++) {
          result.data[i].indexUse=(this.measuringResultPagination.currentPage-1)*this.measuringResultPagination.pageSize+1+i
        }
        // 成功，直接返回 result.data
        return result.data;
      }
    },
    //辅助函数：查询检测结果条目总数
    async queryPrecisionMeasurementValueQuantity(firstName, firstValue, secondName, secondValue, thirdName, thirdValue, forthName, forthValue){
      const result = await this.$request.post('/queryPrecisionMeasurementValueQuantityMacTestCon', {
        firstName: firstName,
        firstValue: firstValue,
        secondName: secondName,
        secondValue: secondValue,
        thirdName: thirdName,
        thirdValue:thirdValue,
        forthName:forthName,
        forthValue:forthValue});
      if (result.code === 401){
        this.$router.push('UserLogin');
        alert("您未登录，请登录");
      }
      else{
        return result.data
      }
    },

    // 处理原始数据每页显示条数的变化
    handleSizeChange(val) {
      this.measuringResultPagination.pageSize = val;
      this.measuringResultPagination.currentPage = 1; // 重置到第一页

      // 使用新的动态查询方法
      const allConditions = this.getCurrentFilterConditions();
      this.queryPrecisionMeasurementValue(allConditions);
    },

// 处理原始数据选择哪页的变化
    handleCurrentChange(val) {
      this.measuringResultPagination.currentPage = val;

      // 使用新的动态查询方法
      const allConditions = this.getCurrentFilterConditions();
      this.queryPrecisionMeasurementValue(allConditions);
    },

// 获取当前筛选条件（包括基础条件和用户输入的筛选条件）
    getCurrentFilterConditions() {
      const baseConditions = this.getBaseConditions();
      const filterParams = {};

      if (this.measuring_project) {
        filterParams.fieldName5 = 'measuring_project';
        filterParams.fieldValue5 = this.measuring_project;
      }
      if (this.part_number) {
        filterParams.fieldName6 = 'part_number';
        filterParams.fieldValue6 = this.part_number;
      }
      if (this.measuring_date) {
        filterParams.fieldName7 = 'measuring_date';
        filterParams.fieldValue7 = this.measuring_date;
      }
      if (this.measuring_person) {
        filterParams.fieldName8 = 'measuring_person';
        filterParams.fieldValue8 = this.measuring_person;
      }
      if (this.measuring_shift) {
        filterParams.fieldName9 = 'measuring_shift';
        filterParams.fieldValue9 = this.measuring_shift;
      }

      return {
        ...baseConditions,
        ...filterParams
      };
    }
  },

  //—————————————————————————————————————————————————————————————————————————————————
  //—————————————————————————————————————————————————————————————————————————————————
  mounted() {
    this.inquiry()
    this.tableData=[]
    this.tableTest=[]
  },

  //—————————————————————————————————————————————————————————————————————————————————
  //—————————————————————————————————————————————————————————————————————————————————
  created() {
    // 初始时显示全部原始数据
    this.filteredTableData = [...this.tableTestVal];
  }
}
</script>

<style scoped>
/* 主体左侧的工作步骤栏用到的数据包围的div的样式*/

.el-footer {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  border-width: 3px; /* 设置边框宽度为3像素 */
  border-color: blue; /* 设置边框颜色为蓝色 */
  border-style: solid; /* 设置边框样式为实线 */
  padding: 10px; /* 添加内边距 */
  border-left-color: white;
  border-top: white;
}

.el-aside {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  border-width: 3px; /* 设置边框宽度为3像素 */
  border-color: blue; /* 设置边框颜色为蓝色 */
  border-style: solid; /* 设置边框样式为实线 */
  padding: 10px; /* 添加内边距 */
  height: 89vh;
}

.el-main {
  color: #333;
  text-align: center;
  border-width: 3px; /* 设置边框宽度为3像素 */
  border-color: blue; /* 设置边框颜色为蓝色 */
  border-left-color: white;
  border-style: solid; /* 设置边框样式为实线 */
  padding: 10px; /* 添加内边距 */
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.headMain{
  color: #ffffff; /* 设置字体颜色为红色 */
  font-size: 18px;
}
.center-text {
  /* 使用 margin-left 和 margin-right auto 来实现居中效果 */
  margin-left: auto;
  margin-right: auto;
  /* 注意：如果 header 内只有这两个元素，你可能不需要 margin-right: auto */
}

/*自定义样式*/

.vLookObjectSelected-row {
  background-color: #e6f7ff; /* 浅蓝色背景 */
  transition: background-color 0.3s ease; /* 添加过渡动画 */
}

</style>